Skip to content

Instantly share code, notes, and snippets.

View at15's full-sized avatar
🐶
Eating

Pinglei Guo at15

🐶
Eating
View GitHub Profile
@jwo
jwo / registrations_controller.rb
Created September 30, 2011 23:11
API JSON authentication with Devise
class Api::RegistrationsController < Api::BaseController
respond_to :json
def create
user = User.new(params[:user])
if user.save
render :json=> user.as_json(:auth_token=>user.authentication_token, :email=>user.email), :status=>201
return
else
@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:

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileWriter;
import java.io.InputStreamReader;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.Vector;
@dmichael
dmichael / gist:5622511
Last active May 25, 2017 17:47
Struct copy/clone
package main
import "fmt"
type Cat struct {
name string
skill string
}
func main() {
@mkhludnev
mkhludnev / q=*%3A*&wt=csv
Last active December 1, 2022 01:28
sample nested documents to demonstrate block join indexing and searching in Solr 4.5
id,_version_,BRAND_s,_root_,type_s,COLOR_s,SIZE_s
12,,,10,,Blue,XL
11,,,10,,Red,XL
10,1445176108735528960,Nike,10,parent,,
22,,,20,,Blue,XL
21,,,20,,Red,M
20,1445176108738674688,Nike,20,parent,,
32,,,30,,Blue,M
31,,,30,,Red,XL
30,1445176108740771840,Puma,30,parent,,

NOTE: This was first authored on 26 Feb 2014. Things may have changed since then.

C++'s Templates

C++'s templates could be seen as forming a duck typed, purely functional code generation program that is run at compile time. Types are not checked at the initial invocation stage, rather the template continues to expand until it is either successful, or runs into an operation that is not supported by that specific type – in that case the compiler spits out a 'stack trace' of the state of the template expansion.

To see this in action, lets look at a very simple example:

template 
@asimjalis
asimjalis / TotalOrderPartitionerExample.java
Created September 25, 2014 07:50
Demonstrates how to use Total Order Partitioner on Word Count.
import java.io.*;
import org.apache.hadoop.conf.*;
import org.apache.hadoop.fs.*;
import org.apache.hadoop.io.*;
import org.apache.hadoop.mapreduce.*;
import org.apache.hadoop.mapreduce.lib.input.*;
import org.apache.hadoop.mapreduce.lib.output.*;
import org.apache.hadoop.mapreduce.lib.partition.*;
import org.apache.hadoop.mapreduce.lib.reduce.*;
@denji
denji / golang-tls.md
Last active June 22, 2024 09:48 — forked from spikebike/client.go
Simple Golang HTTPS/TLS Examples

Moved to git repository: https://github.com/denji/golang-tls

Generate private key (.key)
# Key considerations for algorithm "RSA" ≥ 2048-bit
openssl genrsa -out server.key 2048

# Key considerations for algorithm "ECDSA" ≥ secp384r1
# List ECDSA the supported curves (openssl ecparam -list_curves)
@a-r-m-i-n
a-r-m-i-n / .gitattributes
Last active July 19, 2018 09:25
.gitattributes to force LF for all text files
# Autodetect text files
* text=auto
# Force the following filetypes to have unix eols, so Windows does not break them
*.* text eol=lf
# Force images/fonts to be handled as binaries
*.jpg binary
*.jpeg binary
*.gif binary
@SumitJainUTD
SumitJainUTD / LCS.java
Last active September 17, 2016 08:03
package DynamicProgramming;
public class LongestCommonSubString {
public static int find(char [] A, char [] B){
int [][]LCS = new int [A.length+1][B.length+1];
// if A is null then LCS of A, B =0
for(int i=0;i<=B.length;i++){
LCS[0][i]=0;
}