Skip to content

Instantly share code, notes, and snippets.

@abhi1010
abhi1010 / 0_reuse_code.js
Last active August 29, 2015 14:21
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@abhi1010
abhi1010 / gist:554885a7235f4047dae6
Last active September 2, 2015 14:18 — forked from anonymous/gist:0465925390f3442a7691
Tokenize a String
string strToSplit = "splitting strings, in|multiple ways";
std::vector<std::string> words;
boost::split(words, strToSplit, boost::is_any_of("\t ,|"));
std::copy (words.begin(), words.end(), std::ostream_iterator<string>(cout, "\n"));
words.clear();
std::istringstream iss(strToSplit);
std::copy(std::istream_iterator<std::string>(iss), std::istream_iterator<std::string>(), std::back_inserter(words));
std::copy (words.begin(), words.end(), std::ostream_iterator<string>(cout, "\n"));
@abhi1010
abhi1010 / typename.cpp
Last active September 2, 2015 14:19 — forked from anonymous/typename.cpp
typename usage
template <class T1>
struct OuterStruct
{
T1 mValue;
struct InnerStruct
{
T1 mValue;
};
};
@abhi1010
abhi1010 / generate_diagram.py
Created September 24, 2015 04:19 — forked from jul/generate_diagram.py
building entitty relation ship diagram from a db by using introspection
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from sqlsoup import SQLSoup as sql
from sys import argv
DIGRAPH = """digraph structs {
graph [
rankdir= "LR"
bgcolor=white
]
@abhi1010
abhi1010 / grunt-hugo-lunrjs.md
Created November 4, 2015 16:17 — forked from sebz/grunt-hugo-lunrjs.md
hugo + gruntjs + lunrjs = <3 search
@abhi1010
abhi1010 / config.js
Created April 13, 2016 04:14 — forked from johnlindquist/config.js
RxJS + Angular 2 with 14 different Rx operators all chained together
SystemJS.config({
transpiler: "typescript",
typescriptOptions: {
"experimentalDecorators": true,
"emitDecoratorMetadata": true
},
map: {
"rxjs": "https://npmcdn.com/rxjs",
"angular2": "https://npmcdn.com/angular2",
"@ngrx": "https://npmcdn.com/@ngrx",
@abhi1010
abhi1010 / expand_url.py
Created January 6, 2018 16:18 — forked from vgoklani/expand_url.py
Expand shortened URLs in Python
# http://stackoverflow.com/questions/748324/python-convert-those-tinyurl-bit-ly-tinyurl-ow-ly-to-full-urls
#############
# urllib2
import urllib2
fp = urllib2.urlopen('http://bit.ly/rgCbf')
fp.geturl()
# ==> 'http://webdesignledger.com/freebies/the-best-social-media-icons-all-in-one-place'
import asyncio
loop = asyncio.get_event_loop()
async def hello():
await asyncio.sleep(3)
print('Hello!')
if __name__ == '__main__':
loop.run_until_complete(hello())
@abhi1010
abhi1010 / gist:04ae5e63af2fd629000965b47865521d
Created October 25, 2018 03:34 — forked from rxaviers/gist:7360908
Complete list of github markdown emoji markup

People

:bowtie: :bowtie: πŸ˜„ :smile: πŸ˜† :laughing:
😊 :blush: πŸ˜ƒ :smiley: ☺️ :relaxed:
😏 :smirk: 😍 :heart_eyes: 😘 :kissing_heart:
😚 :kissing_closed_eyes: 😳 :flushed: 😌 :relieved:
πŸ˜† :satisfied: 😁 :grin: πŸ˜‰ :wink:
😜 :stuck_out_tongue_winking_eye: 😝 :stuck_out_tongue_closed_eyes: πŸ˜€ :grinning:
πŸ˜— :kissing: πŸ˜™ :kissing_smiling_eyes: πŸ˜› :stuck_out_tongue:
@abhi1010
abhi1010 / mock.methods.py
Created April 23, 2023 14:58 — forked from Sklavit/mock.methods.py
Mock examples
# @ https://cheat.readthedocs.io/en/latest/python/mock.html
obj.call_count # number of times it was called
obj.called == obj.call_count > 0
obj.call_args_list # a list of (args,kwargs), one for each call
obj.call_args # obj.call_args_list[-1] (args,kwargs from last call)
obj.return_value # set to what it should return
obj.side_effect # set to an exception class or instance that should be raised when its called
obj.assert_called() # doesn't work with autospec=True? just assert obj.called
obj.assert_called_with(*args, **kwargs) # last call was with (*args, **kwargs)