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:376f2787e89fb456bdc8
Created February 5, 2016 03:36
ethereum mining
☁ ~ geth --identity "LocalMiner" --genesis $chaindir/CustomGenesis.json --rpc --rpcport "8545" --rpccorsdomain "*" --datadir "$chaindir/01" --port "30303" --nodiscover --ipcapi "admin,db,eth,debug,miner,net,shh,txpool,personal,web3" --rpcapi "db,eth,net,web3" --autodag --networkid 1467510308 --nat "any" --mine --minerthreads "1"
I0205 11:27:01.206871 19343 database.go:71] Alloted 16MB cache to /Users/lucas/.eth/ebchain/01/chaindata
I0205 11:27:01.210302 19343 database.go:71] Alloted 16MB cache to /Users/lucas/.eth/ebchain/01/dapp
I0205 11:27:01.214214 19343 backend.go:314] Protocol Versions: [63 62 61], Network Id: 1467510308
I0205 11:27:01.214616 19343 genesis.go:89] Genesis block already in chain. Writing canonical number
I0205 11:27:01.214640 19343 backend.go:326] Successfully wrote genesis block. New genesis hash = 27a213a028c685b8017e6b10a30a18008d238857f6f48deee9406d9c4d40d4ac
I0205 11:27:01.214662 19343 backend.go:362] Blockchain DB Version: 3
I0205 11:27:01.215146 19343 blockchain.go:2
@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 / 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>
class DeferredGarbageCollection
DEFERRED_GC_THRESHOLD = (ENV['DEFER_GC'] || 15.0).to_f
@@last_gc_run = Time.now
def self.start
GC.disable if DEFERRED_GC_THRESHOLD > 0
end
@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 / rspec_with_anonymous_controller.rb
Created January 15, 2015 13:25
RSpec with Anonymous controller
require 'rails_helper'
RSpec.describe V1::BaseController, :type => :controller do
before do
Rails.application.routes.draw do
match "/v1/dummy", to: "v1/base#index", via: :all
end
end
@marshluca
marshluca / standup
Last active August 29, 2015 14:07
Open multiple videos with MPlayX on OS X
#!/usr/bin/env ruby
require 'date'
def open_video(file)
file = file.gsub(/\s/, '\\ ')
puts "opening #{file}"
`open #{file} -n /Applications/MPlayerX.app`
end