Skip to content

Instantly share code, notes, and snippets.

👨‍💻
coding

Sagiv Ofek sagivo

👨‍💻
coding
Block or report user

Report or block sagivo

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@sagivo
sagivo / Foo.sol
Last active Jan 18, 2018
Import Obj
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) {
@sagivo
sagivo / gist:3a4b2f2c7ac6e1b5267c2f1f59ac6c6b
Last active Sep 30, 2019
webRTC stun / turn server list
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,
@sagivo
sagivo / foo.js
Created Jun 2, 2016
benchmark of vs in
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');
}
@sagivo
sagivo / bulk-upsert-from-temporary-table.sql
Created Apr 18, 2016 — forked from seanbehan/bulk-upsert-from-temporary-table.sql
Perform an "upsert" from CSV file using Postgres copy command #sql #psql
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 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"
You can’t perform that action at this time.