Skip to content

Instantly share code, notes, and snippets.

@lopopolo
lopopolo / gist:9427762
Created March 8, 2014 09:19
Relink all homebrew formulae after Mavericks upgrade
▶ brew list -1 | while read line; do brew unlink $line; brew link $line; done
Unlinking /usr/local/Cellar/appledoc/2.2... 0 links removed
Linking /usr/local/Cellar/appledoc/2.2... 1 symlinks created
Unlinking /usr/local/Cellar/autoconf/2.69... 0 links removed
Linking /usr/local/Cellar/autoconf/2.69... 18 symlinks created
Unlinking /usr/local/Cellar/bash-completion/1.3... 184 links removed
Linking /usr/local/Cellar/bash-completion/1.3... 182 symlinks created
Unlinking /usr/local/Cellar/bgrep/0.2... 0 links removed
Linking /usr/local/Cellar/bgrep/0.2... 1 symlinks created
Unlinking /usr/local/Cellar/binutils/2.24... 49 links removed
func Escape(sql string) string {
dest := make([]byte, 0, 2*len(sql))
var escape byte
for i := 0; i < len(sql); i++ {
c := sql[i]
escape = 0
switch c {
case 0: /* Must be escaped for 'mysql' */
@sergiotapia
sergiotapia / images_dimensions.go
Last active February 13, 2024 17:40
Golang - Getting the dimensions of an image. jpg, jpeg, png
package main
import (
"fmt"
"image"
"os"
_ "image/jpeg"
_ "image/png"
)
@jed
jed / how-to-set-up-stress-free-ssl-on-os-x.md
Last active February 25, 2024 17:35
How to set up stress-free SSL on an OS X development machine

How to set up stress-free SSL on an OS X development machine

One of the best ways to reduce complexity (read: stress) in web development is to minimize the differences between your development and production environments. After being frustrated by attempts to unify the approach to SSL on my local machine and in production, I searched for a workflow that would make the protocol invisible to me between all environments.

Most workflows make the following compromises:

  • Use HTTPS in production but HTTP locally. This is annoying because it makes the environments inconsistent, and the protocol choices leak up into the stack. For example, your web application needs to understand the underlying protocol when using the secure flag for cookies. If you don't get this right, your HTTP development server won't be able to read the cookies it writes, or worse, your HTTPS production server could pass sensitive cookies over an insecure connection.

  • Use production SSL certificates locally. This is annoying

@johanneswuerbach
johanneswuerbach / .travis.yml
Last active April 14, 2023 20:31
Deploy an iOS app to testflight using Travis CI
---
language: objective-c
before_script:
- ./scripts/travis/add-key.sh
after_script:
- ./scripts/travis/remove-key.sh
after_success:
- ./scripts/travis/testflight.sh
env:
global:
@we11adam
we11adam / .gitconfig
Last active December 16, 2015 09:09
My ~/.gitconfig setup
[user]
name = Adam Lau
email = skyros@gmail.com
[push]
default = current
[mergetool]
keepBackup = true
[merge]
tool = vimdiff
[core]
@arashm
arashm / rbenv_migrate_gems.sh
Created February 3, 2013 09:31
migrate GEMs from rbenv cache to the newer version of ruby (without internet) Thanks to Austin Ziegler - http://stackoverflow.com/questions/13649241/copying-gems-from-previous-version-of-ruby-in-rbenv
#!/bin/sh
# if you're using ZSH, change the shebang above to "#!/bin/zsh -i"
if [ ${#} -ne 2 ]; then
echo >&2 Usage: $(basename ${0}) old-version new-version
exit 1
fi
home_path=$(cd ~; pwd -P)
old_version=${1}
@dergachev
dergachev / GIF-Screencast-OSX.md
Last active April 19, 2024 11:00
OS X Screencast to animated GIF

OS X Screencast to animated GIF

This gist shows how to create a GIF screencast using only free OS X tools: QuickTime, ffmpeg, and gifsicle.

Screencapture GIF

Instructions

To capture the video (filesize: 19MB), using the free "QuickTime Player" application:

@janlay
janlay / whitelist.pac
Last active February 29, 2024 20:23
A white-list based PAC.
/*
* A white-list based PAC without regexp, by @janlay
* It's just simple and fast.
* Last update: Oct 20, 2015
* Special thanks to @Paveo
*/
function FindProxyForURL(url, host) {
// REPLACE PROXY WITH YOUR OWN'S
var PROXY = "SOCKS 127.0.0.1:8801;SOCKS5 127.0.0.1:8801;PROXY 127.0.0.1:8800";
var BLACKHOLE = "127.0.0.2";