View Foo.sol
pragma solidity ^0.4.0; | |
// import the contract | |
import "github.com/sagivo/solidity-utils/contracts/lib/Dictionary.sol"; | |
// have fun | |
contract Foo { | |
// declare and use new Dictionary structure | |
using Dictionary for Dictionary.Data; | |
Dictionary.Data private dic; | |
function Foo() public view returns (uint) { |
View gist:3a4b2f2c7ac6e1b5267c2f1f59ac6c6b
to check if the server works - https://webrtc.github.io/samples/src/content/peerconnection/trickle-ice | |
stun: | |
stun.l.google.com:19302, | |
stun1.l.google.com:19302, | |
stun2.l.google.com:19302, | |
stun3.l.google.com:19302, | |
stun4.l.google.com:19302, | |
stun.ekiga.net, | |
stun.ideasip.com, |
View foo.js
'use strict'; | |
const timer = function(name) { | |
var start = new Date(); | |
return { | |
stop: function() { | |
var end = new Date(); | |
var time = end.getTime() - start.getTime(); | |
console.log('Timer:', name, 'finished in', time, 'ms'); | |
} |
View bulk-upsert-from-temporary-table.sql
create temporary table temp (symbol varchar(255), open decimal, high decimal, low decimal, close decimal, volume varchar(255), date date ); | |
create table if not exists stocks (id serial primary key, symbol varchar(255), open decimal, high decimal, low decimal, close decimal, volume varchar(255), date date, created_at timestamp, updated_at timestamp); | |
copy temp (symbol, date, open, high, low, close, volume) from '/path/to/file.csv' with delimiter ',' csv header; | |
delete from stocks using temp where stocks.date = temp.date and stocks.symbol = temp.symbol; | |
insert into stocks (symbol, open, high, low, close, volume, date) select symbol, open, high, low, close, volume, date from temp; |
View Makefile
all: build | |
build: build_node | |
build_node: node-gyp rebuild |
View 6.cc
#include <nan.h> |
View 2.json
"include_dirs" : ["<!(node -e \"require('nan')\")"] |
View 5.cc
void GetBuffer(const FunctionCallbackInfo<Value>& args) { | |
char *data; | |
size_t length; | |
GetSomeBufferData(data, length); | |
MaybeLocal<Object> buffer = Nan::CopyBuffer(data, length); | |
delete []data; | |
args.GetReturnValue().Set(buffer.ToLocalChecked()); | |
} |
View 4.cc
void GetBuffer(const FunctionCallbackInfo<Value>& args) { | |
char *data; | |
size_t length; | |
GetSomeBufferData(data, length); | |
MaybeLocal<Object> buffer = Nan::NewBuffer(data, length); | |
args.GetReturnValue().Set(buffer.ToLocalChecked()); | |
} |
View hello.js
var addon = require('./build/Release/addon'); | |
console.log(addon.hello('Sam')); // will print "Hello Sam" |
NewerOlder