Skip to content

Instantly share code, notes, and snippets.

View stevesun21's full-sized avatar

stevesun21

  • Somewhere on the earth
View GitHub Profile
@vasanthk
vasanthk / System Design.md
Last active June 29, 2024 13:02
System Design Cheatsheet

System Design Cheatsheet

Picking the right architecture = Picking the right battles + Managing trade-offs

Basic Steps

  1. Clarify and agree on the scope of the system
  • User cases (description of sequences of events that, taken together, lead to a system doing something useful)
    • Who is going to use it?
    • How are they going to use it?
@stevesun21
stevesun21 / CassandraPaging
Last active November 5, 2018 12:24
Cassandra Java Drive Pagination
import com.datastax.driver.core.*;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
/**
* This is a helper class for implementing a pagination function based on Cassandra Java Driver (http://datastax.github.io/java-driver/)
*
* The solution of skipping rows is that use page state rather than iterator rows one by one.
@aioutecism
aioutecism / gist:2638bb9eaf9ffc13348c
Last active June 2, 2024 17:21
Set up a VPN Server (PPTP) on AWS and use it anywhere

Set up a VPN Server (PPTP) on AWS

  1. Create a EC2 instance using Ubuntu 14.04.
  2. In Secure Group Inbound Rules, add a SSH Rule(TCP, Port 22, 0.0.0.0/0) and a Custom TCP Rule(TCP, Port 1723, 0.0.0.0/0).
  3. Optional: Associate a Elastic IP with the instance.
  4. SSH into the instance.
  5. sudo apt-get install pptpd.
  6. sudo vim /etc/pptpd.conf. Uncomment localip 192.168.0.1 and remoteip 192.168.0.234-238,192.168.0.245.
  7. sudo vim /etc/ppp/pptpd-options. Uncomment ms-dns and ms-wins. Change the IP to Google's DNS like this:
@Abizern
Abizern / loggingPrint.swift
Last active September 22, 2021 14:28
Debug logging for Swift
//
// LoggingPrint.swift
//
import Foundation
/**
Prints the filename, function name, line number and textual representation of `object` and a newline character into
the standard output if the build setting for "Active Complilation Conditions" (SWIFT_ACTIVE_COMPILATION_CONDITIONS) defines `DEBUG`.
#!/bin/bash -ex
# Wrapper for 'docker save' fixing,
# https://github.com/dotcloud/docker/issues/3877
# In addition: this script will always save exactly one image (possibly
# multiple tags).
IMAGE=$1
TARGET=$2
NAME=`echo $IMAGE | awk -F':' '{print $1}'`
ID=`docker inspect $IMAGE | python -c "import sys,json; print json.load(sys.stdin)[0]['id']"`
@ryandotsmith
ryandotsmith / Dockerfile
Last active December 13, 2016 10:48
EC2 Docker Setup
FROM ubuntu
MAINTAINER "Bobby Wilson"
RUN apt-get update
RUN apt-get install curl -y
RUN cd /usr/local; curl -O http://nodejs.org/dist/v0.10.16/node-v0.10.16-linux-x64.tar.gz
RUN cd /usr/local; tar xzf node-v0.10.16-linux-x64.tar.gz
ENV PATH /usr/local/bin:/usr/sbin:/bin:/usr/local/node-v0.10.16-linux-x64/bin
ADD . /app
EXPOSE 8000:8000
ENV PORT 8000
@dergachev
dergachev / GIF-Screencast-OSX.md
Last active June 5, 2024 22:16
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:

@orip
orip / GsonHelper.java
Created September 5, 2012 11:22
Gson type adapter to serialize and deserialize byte arrays in base64
import java.lang.reflect.Type;
import android.util.Base64;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.JsonDeserializationContext;
import com.google.gson.JsonDeserializer;
import com.google.gson.JsonElement;
import com.google.gson.JsonParseException;
@stevesun21
stevesun21 / gist:2480559
Created April 24, 2012 15:21
Java implemented number wording translator
public class NumberWordingTranslator {
private final static String[] hundredWords={
"Zero", "One", "Two", "Three", "Four", "Five", "Six", "Seven", "Eight", "Nine",
"Ten", "Eleven", "Twelve", "Thirteen", "Fourteen", "Fifteen", "Sixteen", "Seventeen", "Eighteen", "Nineteen",
"Twenty", null, null, null, null, null, null, null, null, null,
"Thirty", null, null, null, null, null, null, null, null, null,
"Forty", null, null, null, null, null, null, null, null, null,
"Fifty", null, null, null, null, null, null, null, null, null,
"Sixty", null, null, null, null, null, null, null, null, null,
@oodavid
oodavid / README.md
Created March 26, 2012 17:05
Backup MySQL to Amazon S3

Backup MySQL to Amazon S3

This is a simple way to backup your MySQL tables to Amazon S3 for a nightly backup - this is all to be done on your server :-)

Sister Document - Restore MySQL from Amazon S3 - read that next

1 - Install s3cmd

this is for Centos 5.6, see http://s3tools.org/repositories for other systems like ubuntu etc