Skip to content

Instantly share code, notes, and snippets.

@Koze
Koze / PhotosCameraRoll.m
Last active February 3, 2018 06:26
Getting Camera Roll with Photos.framework
View PhotosCameraRoll.m
PHFetchResult *result = [PHAssetCollection fetchAssetCollectionsWithType:PHAssetCollectionTypeSmartAlbum
subtype:PHAssetCollectionSubtypeSmartAlbumUserLibrary
options:nil];
PHAssetCollection *assetCollection = result.firstObject;
NSLog(@"%@", assetCollection.localizedTitle);
// Camera Roll
@dsemenovsky
dsemenovsky / watchTokenTransfers.js
Created June 1, 2018 23:56
Token transfers watcher
View watchTokenTransfers.js
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) }
)
@tuncbahcecioglu
tuncbahcecioglu / auth_twitter_login.js
Created December 14, 2012 23:13
node.js oauth example: logins to twitter, displays user name
View auth_twitter_login.js
// 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';
@JadenGeller
JadenGeller / Swift Atomic Operators.swift
Created March 17, 2015 01:38
Swift Atomic Operators
View Swift Atomic Operators.swift
import Foundation
infix operator +=! { associativity right precedence 90 } // Int32 or Int64
infix operator -=! { associativity right precedence 90 } // Int32 or Int64
postfix operator ++! {} // Int32 or Int64
postfix operator --! {} // Int32 or Int64
infix operator |=! { associativity right precedence 90 } // UInt32
infix operator &=! { associativity right precedence 90 } // UInt32
@dsemenovsky
dsemenovsky / confirmEtherTransaction.js
Created June 1, 2018 23:59
Confirm Ethereum transaction
View confirmEtherTransaction.js
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
@berzniz
berzniz / NSObject+Debounce.h
Created January 25, 2014 16:18
Debounce method for Objective C
View NSObject+Debounce.h
@interface NSObject (Debounce)
- (void)debounce:(SEL)action delay:(NSTimeInterval)delay;
@end
@dsemenovsky
dsemenovsky / watchEtherTransfers.js
Created June 1, 2018 23:55
Ether transfers watcher
View watchEtherTransfers.js
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)
@yoggy
yoggy / uuid_test.c
Created January 8, 2013 11:19
libuuid sample program
View uuid_test.c
//
// libuuid sample program
//
// library install for debian
// $ sudo apt-get install uuid-dev
//
// compile
// $ gcc uuid_test.c -luuid -o uuid_test
//
#include <stdio.h>
@dsemenovsky
dsemenovsky / getConfirmations.js
Created June 1, 2018 23:58
Get Ethereum transaction confirmations count
View getConfirmations.js
async function getConfirmations(txHash) {
try {
// Instantiate web3 with HttpProvider
const web3 = new Web3('https://rinkeby.infura.io/')
// Get transaction details
const trx = await web3.eth.getTransaction(txHash)
// Get current block number
const currentBlock = await web3.eth.getBlockNumber()
@chriseth
chriseth / 0 README.md
Last active November 6, 2022 19:55
Formal verification for re-entrant Solidity contracts
View 0 README.md

This gist shows how formal conditions of Solidity smart contracts can be automatically verified even in the presence of potential re-entrant calls from other contracts.

Solidity already supports formal verification of some contracts that do not make calls to other contracts. This of course excludes any contract that transfers Ether or tokens.

The Solidity contract below models a crude crowdfunding contract that can hold Ether and some person can withdraw Ether according to their shares. It is missing the actual access control, but the point that wants to be made