Skip to content

Instantly share code, notes, and snippets.

@tinoji
tinoji / proxmox_lxc_pct_provisioner.sh
Created February 7, 2018 01:02
Create and provision Proxmox LXC by pct command
pct create <id> /var/lib/vz/template/cache/centos-7-default_20170504_amd64.tar.xz \
-arch amd64 \
-ostype <centos|ubuntu|etc> \
-hostname <hostname> \
-cores <cores> \
-memory <memory(MB)> \
-swap <swap(MB)> \
-storage local-lvm \
-password \
-net0 name=eth0,bridge=<bridge>,gw=<gateway>,ip=<cidr>,type=veth &&\
@raineorshine
raineorshine / sendRawTransaction.js
Last active December 3, 2022 18:02
Sends a raw transaction with web3 v1.2.2, ethereumjs-tx v2.1.1, and Infura
const Web3 = require('web3')
const Tx = require('ethereumjs-tx').Transaction
// connect to Infura node
const web3 = new Web3(new Web3.providers.HttpProvider('https://mainnet.infura.io/INFURA_KEY'))
// the address that will send the test transaction
const addressFrom = '0x1889EF49cDBaad420EB4D6f04066CA4093088Bbd'
const privateKey = new Buffer('PRIVATE_KEY', 'hex')
@c9s
c9s / .babelrc
Last active October 21, 2023 14:04
webpack + babel + typescript + es6 - total solutions!
{
"presets": ["es2015"],
"plugins": ["transform-runtime"]
}
@chenglou
chenglou / smallestTemplateEngineEver.coffee
Created June 20, 2013 02:21
It actually works perfectly, can you believe it? Inspired by coffeekup.
# 21 lines, gutter at 80, for a fully functional coffeescript templater.
global.compiledHTML = ''
makeTagFunc = (tagName, isSelfClosing) ->
(args...) ->
selfEndingTag = if isSelfClosing then ' /' else ''
attrs = args.filter((i) -> typeof i is 'object').reduce(((i, j) ->
i + ("#{key}='#{val}'" for key, val of j).join ' '), '')
inner = args.filter((i) ->
typeof i != 'function' and typeof i != 'object').map((i) -> i).join ' '
global.compiledHTML += "<#{(tagName + ' ' + attrs).trim()}#{selfEndingTag}>"
@pH200
pH200 / gist:3852437
Created October 8, 2012 13:10
node async foreach
Array.prototype.forEachAsync = function (callback, complete) {
var raiseComplete/*: (arg?: bool) => void*/ = complete ? (function (arg) {
complete(arg);
}) : (function () { });
function next (self, index, length) { /* rec */
if (index === length) {
raiseComplete(true);
} else {
process.nextTick(function () {
@prozacgod
prozacgod / synchro.js
Created June 9, 2011 20:43
node.js synchronize multiple actions
/*
A simple and elegant function to synchronize multiple functions that expect callback as their last parameter.
example:
sync(func1, [parms], func2, func3, func4, [parms], callback);
Public domain!!
please leave me a comment if you like it!
*/
# These are my notes from the PragProg book on CoffeeScript of things that either
# aren't in the main CS language reference or I didn't pick them up there. I wrote
# them down before I forgot, and put it here for others but mainly as a reference for
# myself.
# assign arguments in constructor to properties of the same name:
class Thingie
constructor: (@name, @url) ->
# is the same as:
@thelinuxlich
thelinuxlich / model.coffee
Created March 3, 2011 20:25
Sample Knockout.js model written in Coffeescript
# Modelo base
class @Model
constructor: (defaults,urls) ->
@__defaults = if typeof defaults is "object" then defaults else {}
@__urls = if typeof urls is "object" then defaults else {}
@set(@__defaults)
get: (attr) ->
ko.unwrapObservable @[attr]
@xdite
xdite / gist:758319
Created December 29, 2010 07:56
Ruby / Rails Convention of Techbang

Rails 開發注意要點

About Ruby Syntax

  • 編輯器設定 soft tab (space=2),以 2 格空白符號做為程式內縮距離(不分語言)。
  • 函式如果只有一個參數,就不強制打()
  • 函式如果有二個以上的參數,通通都要有 ()
    • (避免發生奇怪的paser bug跟保持專案一致性)
  • 字串限定用雙引號包覆
  • 善用 "#{str1} #{str3} " 等字串改寫技巧取代不需要的字串加法。