Skip to content

Instantly share code, notes, and snippets.

@wojteklu
wojteklu / clean_code.md
Last active May 11, 2024 07:08
Summary of 'Clean code' by Robert C. Martin

Code is clean if it can be understood easily – by everyone on the team. Clean code can be read and enhanced by a developer other than its original author. With understandability comes readability, changeability, extensibility and maintainability.


General rules

  1. Follow standard conventions.
  2. Keep it simple stupid. Simpler is always better. Reduce complexity as much as possible.
  3. Boy scout rule. Leave the campground cleaner than you found it.
  4. Always find root cause. Always look for the root cause of a problem.

Design rules

@the-bass
the-bass / rename_state_dict_keys.py
Last active May 11, 2024 07:07
Rename the parameters of a PyTorch module's saved state dict. Last tested with PyTorch 1.0.1.
import torch
from collections import OrderedDict
def rename_state_dict_keys(source, key_transformation, target=None):
"""
source -> Path to the saved state dict.
key_transformation -> Function that accepts the old key names of the state
dict as the only argument and returns the new key name.
target (optional) -> Path at which the new state dict should be saved

MongoDB Cheat Sheet

Show All Databases

show dbs

Show Current Database

@RobTrew
RobTrew / soundDeviceToggle.js
Last active May 11, 2024 07:04
Toggling OS X Sound Output Devices with JXA Javascript for Automation (OS X 10.10)
// Rob Trew @complexpoint 2015
function run() {
"use strict";
var blnUseKeyboardMaestro = false;
// EDIT TO NAMES OF TWO ALTERNATIVE SOUND OUTPUT DEVICES
var dctSources = { // A unique substring for each is enough
primary: "Internal",
secondary: "Elgato"
@bryanbraun
bryanbraun / git-branching-diagram.md
Last active May 11, 2024 07:03
Example Git Branching Diagram

Example Git Branching Diagram

You can use this diagram as a template to create your own git branching diagrams. Here's how:

  1. Create a new diagram with diagrams.net (formerly draw.io)
  2. Go to File > Open From > URL
  3. Insert this url (it points to the xml data below): https://gist.githubusercontent.com/bryanbraun/8c93e154a93a08794291df1fcdce6918/raw/bf563eb36c3623bb9e7e1faae349c5da802f9fed/template-data.xml
  4. Customize as needed for your team.

@DavFount
DavFount / AutoDBBackup.ps1
Last active May 11, 2024 07:03
Auto-Backup MariaDB Database (Windows)
param(
[Parameter(Mandatory, HelpMessage = 'Path to Maria DB Installation. C:\Program Files\MariaDB 10.9')]
[string]$SQLPath,
[Parameter(Mandatory, HelpMessage = 'Location to store backups. C:\DBServerBackups')]
[string]$BackupDirectory,
[Parameter(Mandatory, HelpMessage = 'SQL User with access to your DB.')]
[string]$User,
[Parameter(Mandatory, HelpMessage = 'Password for the SQL User.')]
[string]$Pass,
[Parameter(HelpMessage = 'Port Number for your SQL Instance. Default: 3306')]
@RobTrew
RobTrew / KMVars.js
Last active May 11, 2024 07:02
Example: accessing Keyboard Maestro variables from Yosemite JXA Javascript for Applications
function run() {
// KEYBOARD MAESTRO VARIABLES IN YOSEMITE JXA JAVASCRIPT FOR APPLICATIONS
// FINDING, CREATING, READING, UPDATING
// SIMPLE EXAMPLE - TOGGLING A BOOLEAN KM VARIABLE FROM .js
var strKMVarName = "flag";
@dtinth
dtinth / README.md
Created October 29, 2014 15:18
iPhoto Location Export

iPhotoLocation

Exports the locations of photos in a photo album as JSON data...

osascript -l JavaScript iPhotoLocation.js "NAIST Internship"
@lopspower
lopspower / README.md
Last active May 11, 2024 06:59
Hexadecimal color code for transparency

Hexadecimal color code for transparency

Twitter

How to set transparency with hex value ?

For example, you want to set 40% alpha transparence to #000000 (black color), you need to add 66 like this #66000000.

Download This sample on Google Play Store