Skip to content

Instantly share code, notes, and snippets.

View marshluca's full-sized avatar
🏠
Working from home

Lucas Zhang marshluca

🏠
Working from home
View GitHub Profile
@marshluca
marshluca / gist:a1a1da1971f5c1c93fc2
Created February 3, 2016 12:23
EI Capitan usb installer
Lucas-MacBook-Pro:~ lucas$ sudo /Applications/Install\ OS\ X\ El\ Capitan.app/Contents/Resources/createinstallmedia --volume /Volumes/Lucas/ --applicationpath /Applications/Install\ OS\ X\ El\ Capitan.app/
Password:
Ready to start.
To continue we need to erase the disk at /Volumes/Lucas/.
If you wish to continue type (Y) then press return: Y
Erasing Disk: 0%... 10%... 20%... 30%...100%...
Copying installer files to disk...
Copy complete.
Making disk bootable...
Copying boot files...
@marshluca
marshluca / admin.peers.txt
Created January 21, 2016 03:06
admin.peers for `geth console`
[{
caps: ["eth/61", "eth/62", "eth/63"],
id: "1118980bf48b0a3640bdba04e0fe78b1add18e1cd99bf22d53daac1fd9972ad650df52176e7c7d89d1114cfef2bc23a2959aa54998a46afcf7d91809f0855082",
name: "Geth/v1.3.3-c541b38f/linux/go1.5.1",
network: {
localAddress: "192.168.0.108:54680",
remoteAddress: "52.74.57.123:30303"
},
protocols: {
eth: {
@marshluca
marshluca / truncate.css
Created January 20, 2016 07:34
Truncate overflow text with dots
.truncate {
width: 250px;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
@marshluca
marshluca / eval_benchmark.rb
Last active January 20, 2016 04:41
eval vs send
require 'benchmark'
require 'active_support/inflector'
class Foo
def self.bar
end
end
def with_eval
eval "Foo.bar"
@marshluca
marshluca / 3des.rb
Created October 16, 2015 06:59
3 des
def encrypted_password(password)
if password.length < 8
password = "#{password}#{'0'*(8-password.length)}"
end
key = "12345678"
secret = "1234567890" + password + "123456"
# des-ede3-cbc Three key triple DES EDE in CBC mode
# des-ede3 Three key triple DES EDE in ECB mode
require 'net/http'
# Create the SOAP Envelope
data = <<-EOF
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<GetInvoiceNumber xmlns="testinvoice.PayNow.com.tw">
<mem_cid>70828783</mem_cid>
<Year>2015</Year>
@marshluca
marshluca / gist:2308868
Created April 5, 2012 07:57 — forked from jrochkind/gist:2161449
A Capistrano Rails Guide

A Capistrano Rails Guide

by Jonathan Rochkind, http://bibwild.wordpress.com

why cap?

Capistrano automates pushing out a new version of your application to a deployment location.

I've been writing and deploying Rails apps for a while, but I avoided using Capistrano until recently. I've got a pretty simple one-host deployment, and even though everyone said Capistrano was great, every time I tried to get started I just got snowed under not being able to figure out exactly what I wanted to do, and figured I wasn't having that much trouble doing it "manually".

From d3bb57d8e3974f2f6101184aafe4f4841b7af3f4 Mon Sep 17 00:00:00 2001
From: Lin Zhang <marshluca@gmail.com>
Date: Fri, 2 Mar 2012 11:36:06 +0800
Subject: [PATCH] defind method Wallpaper.upload
---
app/models/wallpaper.rb | 12 ++++++++++--
1 files changed, 10 insertions(+), 2 deletions(-)
diff --git a/app/models/wallpaper.rb b/app/models/wallpaper.rb
@marshluca
marshluca / explicit-vs-implicit-benchmark.rb
Created November 10, 2011 17:11
Explicit vs implicit
require 'benchmark'
def explicit
return "TEST"
end
def implicit
"TEST"
end
@marshluca
marshluca / MyAppDelegate.m
Created October 24, 2011 04:03 — forked from Nitewriter/MyAppDelegate.m
UINavigationController custom navigation bar
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
// Override point for customization after application launch.
// Create a new window and assign directly to provided iVar
_window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
// Implementation of new init method
MyCustomNavigationBar *navigationBar = [[MyCustomNavigationBar alloc] initWithFrame:CGRectZero];
UINavigationController *navigationController = [[UINavigationController alloc] initWithCustomNavigationBar:navigationBar];