Skip to content

Instantly share code, notes, and snippets.

View cuber's full-sized avatar

Cube cuber

View GitHub Profile
@tathamoddie
tathamoddie / Swap unique values.sql
Created August 5, 2010 01:36
Swap two values in SQL that have a unique constraint
SET NOCOUNT ON
CREATE TABLE Foo
(
Id int primary key,
SortIndex int unique
)
GO
@streadway
streadway / uuid22.c
Created September 12, 2012 21:29
Example UUID in 22 bytes. Linux: `cc -luuid uuid22.c` Darwin: `cc uuid22.c`
#include <stdio.h>
#include <uuid/uuid.h>
#include <sys/types.h>
u_int64_t bits2uint64(unsigned char const bits[]) {
return ((u_int64_t)bits[0] << 56)
| ((u_int64_t)bits[1] << 48)
| ((u_int64_t)bits[2] << 40)
| ((u_int64_t)bits[3] << 32)
@skyscribe
skyscribe / .gdbinit
Created October 30, 2012 03:04
GDB init file to print STL containers and data members
#
# STL GDB evaluators/views/utilities - 1.03
#
# The new GDB commands:
# are entirely non instrumental
# do not depend on any "inline"(s) - e.g. size(), [], etc
# are extremely tolerant to debugger settings
#
# This file should be "included" in .gdbinit as following:
# source stl-views.gdb or just paste it into your .gdbinit file
@taldanzig
taldanzig / osxvpnrouting.markdown
Created January 24, 2013 22:14
Routing tips for VPNs on OS X

Routing tips for VPNs on OS X

When VPNs Just Work™, they're a fantastic way of allowing access to a private network from remote locations. When they don't work it can be an experience in frustration. I've had situations where I can connect to a VPN from my Mac, but various networking situations cause routing conflicts. Here are a couple of cases and how I've been able to get around them.

Specific cases

Case 1: conflicting additional routes.

In this example the VPN we are connecting to has a subnet that does not conflict with our local IP, but has additional routes that conflict in some way with our local network's routing. In my example the remote subnet is 10.0.x.0/24, my local subnet is 10.0.y.0/24, and the conflicting route is 10.0.0.0/8. Without the later route, I can't access all hosts on the VPN without manually adding the route after connecting to the VPN:

@radu-gheorghe
radu-gheorghe / multiple_child_levels.bash
Created April 23, 2013 09:04
multiple parent-child level query with Elasticsearch
curl -XDELETE localhost:9200/test/
curl -XPUT localhost:9200/test/
curl -XPUT localhost:9200/test/son/_mapping -d '{
"son": {
"_parent": {
"type": "mother"
}
}
}'
curl -XPUT localhost:9200/test/daughter/_mapping -d '{
@ssstonebraker
ssstonebraker / sed cheatsheet
Created August 2, 2013 14:06 — forked from un33k/sed cheatsheet
Sed Cheatsheet
FILE SPACING:
# double space a file
sed G
# double space a file which already has blank lines in it. Output file
# should contain no more than one blank line between lines of text.
sed '/^$/d;G'
@pyrocat101
pyrocat101 / ip-address-regex.js
Created November 20, 2013 18:44
IPv4 and IPv6 Address RegExp
var IPV4 = /^(25[0-5]|2[0-4][0-9]|1?[0-9][0-9]{1,2})(\.(25[0-5]|2[0-4][0-9]|1?[0-9]{1,2})){3}$/,
IPV6 = /^([0-9a-f]){1,4}(:([0-9a-f]){1,4}){7}$/i;
@samuel
samuel / thriftserde.go
Created May 27, 2014 18:25
Example of Thrift struct serialization / deserialization
package main
import (
"bytes"
"log"
"github.com/samuel/go-thrift/thrift"
)
type testStruct struct {
@qhhonx
qhhonx / weibo.py
Last active December 20, 2016 08:26
Login assist for Sina Weibo which can process verify code required situation.(新浪微博登录实现,包含验证码解析)
# coding=utf8
import base64
import binascii
import cookielib
import json
import os
import random
import re
import rsa
import time