start new:
tmux
start new with session name:
tmux new -s myname
from sqlalchemy.dialects import postgresql | |
def bulk_upsert(session: Session, | |
items: Sequence[Mapping[str, Any]]): | |
session.execute( | |
postgresql.insert(MyModel.__table__) | |
.values(items) | |
.on_conflict_do_update( | |
index_elements=[MyModel.id], | |
set_={MyModel.my_field.name: 'new_value'}, |
#!/usr/bin/env bash | |
# | |
# Fix virtualenv symlinks after upgrading python with Homebrew and then running | |
# `cleanup`. | |
# | |
# After upgrading Python using Homebrew and then running `brew cleanup` one can | |
# get this message while trying to run python: | |
# dyld: Library not loaded: @executable_path/../.Python | |
# Referenced from: /Users/pablo/.venv/my-app/bin/python | |
# Reason: image not found |
""" | |
Located under app/ | |
""" | |
import os | |
from django.apps import apps | |
from django.conf import settings | |
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "settings") |
func keyCodeToString(keyCode: CGKeyCode) -> String { | |
let curKeyboard = TISCopyCurrentKeyboardInputSource().takeRetainedValue() | |
let ptr = TISGetInputSourceProperty(curKeyboard, kTISPropertyUnicodeKeyLayoutData) | |
let keyboardLayoutPtr = UnsafePointer<UCKeyboardLayout>(ptr) | |
var deadKeyState: UInt32 = 0 | |
var actualStringLength = 0 | |
var unicodeString = [UniChar](count: 255, repeatedValue: 0) | |
let status = UCKeyTranslate(keyboardLayoutPtr, |
Find it here: https://github.com/bitemyapp/learnhaskell
mem_size = 64 | |
mem_prot = 0x40 # PAGE_EXECUTE_READWRITE | |
mem_type = 0x00001000 # MEM_COMMIT | |
ex_mem = ccall(:VirtualAlloc, | |
Ptr{Uint8}, | |
(Ptr{Void}, Csize_t, Uint64, Uint64), | |
C_NULL, mem_size, mem_type, mem_prot) # call VirtualAlloc and get executable page | |
exec_arr = pointer_to_array(ex_mem, (32,2)); # consider as an array so we can write to it |
#!/bin/sh | |
KERNEL="/path/to/vmlinuz64" | |
INITRD="/path/to/initrd.img" | |
#CMDLINE="earlyprintk=serial console=ttyS0 acpi=off" | |
CMDLINE="loglevel=3 user=docker console=ttyS0 console=tty0 noembed nomodeset norestore waitusb=10:LABEL=boot2docker-data base" | |
MEM="-m 1G" | |
#SMP="-c 2" | |
NET="-s 2:0,virtio-net,en0" |
location ~ ^/(wp-admin|wp-login\.php|priv\.dog|companies\/sidekick) { | |
deny all; | |
break; | |
} | |
# file extensions that should never be served, this prevents | |
# potential malicious downloads in case someone manages to manipulate | |
# a Rails URL or write a file that can be served | |
# (~* matches case-insensitive) | |
location ~* \.(?:git|svn|DS_Store|asp|aspx|cgi|pt|pl|idx|php|exe|scpt|AppleScript|dll|dmg|pif|msi|application|msp|com|scr|hta|cpl|gadget|msc|jar|bat|vb|vbs|vbe|ws|wsh|inf|lnk|reg|scf|wsc|wsh|ps1|ps1xml|ps2|ps2xml|psc1|psc2|msh|msh1|msh2|mshxml|msh1xml|msh2xml)$ { | |
deny all; |
"use strict"; | |
// Uses jQuery and Q. | |
var API_KEY = "whatever"; | |
function getFlickrResponseAsync(method, responseProperty, params) { | |
var deferred = Q.defer(); | |
$.ajax("http://www.flickr.com/services/rest/", { |