Skip to content

Instantly share code, notes, and snippets.

View sagivo's full-sized avatar
👨‍💻
coding

Sagiv Ofek sagivo

👨‍💻
coding
View GitHub Profile
@sagivo
sagivo / Foo.sol
Last active January 18, 2018 21:48
Import Obj
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) {
@sagivo
sagivo / gist:3a4b2f2c7ac6e1b5267c2f1f59ac6c6b
Last active November 1, 2024 11:38
webRTC stun / turn server list
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,
@sagivo
sagivo / foo.js
Created June 2, 2016 19:05
benchmark of vs in
'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');
}
@sagivo
sagivo / bulk-upsert-from-temporary-table.sql
Created April 18, 2016 19:05 — forked from seanbehan/bulk-upsert-from-temporary-table.sql
Perform an "upsert" from CSV file using Postgres copy command #sql #psql
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;
all: build
build: build_node
build_node: node-gyp rebuild
@sagivo
sagivo / 6.cc
Created September 30, 2015 16:49
#include <nan.h>
@sagivo
sagivo / 2.json
Created September 30, 2015 16:49
"include_dirs" : ["<!(node -e \"require('nan')\")"]
@sagivo
sagivo / 5.cc
Created September 30, 2015 16:48
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());
}
@sagivo
sagivo / 4.cc
Created September 30, 2015 16:47
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());
}
@sagivo
sagivo / hello.js
Last active September 30, 2015 16:54
var addon = require('./build/Release/addon');
console.log(addon.hello('Sam')); // will print "Hello Sam"