Skip to content

Instantly share code, notes, and snippets.

View sanandnarayan's full-sized avatar

Anand Narayan sanandnarayan

View GitHub Profile
// SPDX-License-Identifier: UNLICENSED
pragma solidity <=0.8.20;
pragma abicoder v2;
// OpenZeppelin Contracts v4.4.1 (token/ERC721/extensions/IERC721Metadata.sol)
// OpenZeppelin Contracts (last updated v4.8.0) (token/ERC721/IERC721.sol)
// OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol)
@sanandnarayan
sanandnarayan / PositionHelper.sol
Created June 15, 2023 05:57
IPositionsHelper
// SPDX-License-Identifier: UNLICENSED
pragma solidity <=0.8.20;
import "v3-periphery/interfaces/INonfungiblePositionManager.sol";
// https://github.com/Uniswap/v3-periphery/blob/0.8/contracts/interfaces/INonfungiblePositionManager.sol
interface IPositionsHelper {
struct Position {
uint96 nonce;
@sanandnarayan
sanandnarayan / screencapture
Created April 24, 2019 00:37
screencapture
mkdir ~/Desktop/screenshots
while :;do screencapture -x ~/Desktop/screenshots/$(date +%y%m%d%H%M%S).png;sleep 120;done
# daily at 10pm
convert *.png movie.mpeg
mv movie.mpeg ~/Desktop
@sanandnarayan
sanandnarayan / method_override.rb
Created November 27, 2013 07:38
Temporarily over-riding classes in ruby
# Ever wondered, how RSpec does Stubbing.
# They use Ruby's metaprogamming abilities.
# Lets talk a closer look.
# Every class in ruby inherits from a special class
# named "Object" .
class Object
# We are adding a mock_methods function which will be available to every
# object.
@sanandnarayan
sanandnarayan / waitprint.js
Created August 23, 2013 11:45
Wait and Print
// problem: why does it log out out 1000?
// fix it to log 100, 200, 300, 400, 500 etc
// loops 10 times from 0 - 1000 in increments of 100
for (var i = 0; i < 1000; i += 100) {
waitFor(i, function then() {
console.log(i)
})
}
@sanandnarayan
sanandnarayan / dhoni.js
Created August 23, 2013 11:44
why cant Dhone introduce himself?
// question: why cant Dhone introduce himself?
// please fix it. Make Dhoni introduce himself!
var Man = function( name ) {
this.name = name
}
Man.prototype.introduce = function() {
console.log( this.name )
}
/*
Question: Find the shortest path and distance between two cities
Roads is an array of routes between cities.
The routes are of the format [Source, Destination1, distance, Destination2, distance, etc]
That is ["kangeyam", "hosur", 19,
"faridabad", 15, "trichy", 15]
Signifies that the road betweeen
@sanandnarayan
sanandnarayan / .gitignore
Created August 27, 2012 12:59
Albers USA states
d3
.DS_Store
@sanandnarayan
sanandnarayan / make_call.rb
Created April 9, 2012 08:08
Plivo ruby make a call
require './plivohelper.rb'
#URL of the Plivo REST service
REST_API_URL = 'https://api.plivo.com/v1/'
# Sid and AuthToken
SID = 'MAJKMWIXMDQXZDCZNMEZ'
AUTH_TOKEN = 'YTNlNWI0MzZhNWQ0OGJlNmVkOTExZDgxYjIyMTU4'
#Define Channel Variable - http://wiki.freeswitch.org/wiki/Channel_Variables
extra_dial_string = "bridge_early_media=true,hangup_after_bridge=true"
@sanandnarayan
sanandnarayan / chaning.js
Created February 11, 2012 06:02
chaining in js
var chaining = function(){
this.count = 1;
this.increment = function(){
this.count++;
this.addition = function(v){
this.count += v;
this.shout = function(){
console.log("I am shouting dadad...." + this.count);
return this;
};