Skip to content

Instantly share code, notes, and snippets.

@dsemenovsky
dsemenovsky / watchEtherTransfers.js
Created June 1, 2018 23:55
Ether transfers watcher
function watchEtherTransfers() {
// Instantiate web3 with WebSocket provider
const web3 = new Web3(new Web3.providers.WebsocketProvider('wss://rinkeby.infura.io/ws'))
// Instantiate subscription object
const subscription = web3.eth.subscribe('pendingTransactions')
// Subscribe to pending transactions
subscription.subscribe((error, result) => {
if (error) console.log(error)
@berzniz
berzniz / NSObject+Debounce.h
Created January 25, 2014 16:18
Debounce method for Objective C
@interface NSObject (Debounce)
- (void)debounce:(SEL)action delay:(NSTimeInterval)delay;
@end
@dsemenovsky
dsemenovsky / confirmEtherTransaction.js
Created June 1, 2018 23:59
Confirm Ethereum transaction
function confirmEtherTransaction(txHash, confirmations = 10) {
setTimeout(async () => {
// Get current number of confirmations and compare it with sought-for value
const trxConfirmations = await getConfirmations(txHash)
console.log('Transaction with hash ' + txHash + ' has ' + trxConfirmations + ' confirmation(s)')
if (trxConfirmations >= confirmations) {
// Handle confirmation event according to your business logic
@tuncbahcecioglu
tuncbahcecioglu / auth_twitter_login.js
Created December 14, 2012 23:13
node.js oauth example: logins to twitter, displays user name
// https://gist.github.com/1964797
var express = require('express');
var sys = require('util');
var oauth = require('oauth');
var app = express();
var _twitterConsumerKey = 'sLNC1nUodJom3L8BNL4iHA';
var _twitterConsumerSecret = 'EcO8Iiv5M8R0qeLVbHAi2cm9uX4Fp1jPODnoGfqUEro';
@dsemenovsky
dsemenovsky / watchTokenTransfers.js
Created June 1, 2018 23:56
Token transfers watcher
function watchTokenTransfers() {
// Instantiate web3 with WebSocketProvider
const web3 = new Web3(new Web3.providers.WebsocketProvider('wss://rinkeby.infura.io/ws'))
// Instantiate token contract object with JSON ABI and address
const tokenContract = new web3.eth.Contract(
TOKEN_ABI, process.env.TOKEN_CONTRACT_ADDRESS,
(error, result) => { if (error) console.log(error) }
)
@Koze
Koze / PhotosCameraRoll.m
Last active February 3, 2018 06:26
Getting Camera Roll with Photos.framework
PHFetchResult *result = [PHAssetCollection fetchAssetCollectionsWithType:PHAssetCollectionTypeSmartAlbum
subtype:PHAssetCollectionSubtypeSmartAlbumUserLibrary
options:nil];
PHAssetCollection *assetCollection = result.firstObject;
NSLog(@"%@", assetCollection.localizedTitle);
// Camera Roll