This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from colorama import Fore, Back, Style | |
def my_decorator(func): | |
def wrapper(): | |
print("Something is happening before the function is called.") | |
print(Fore.GREEN) | |
func() | |
print(Style.RESET_ALL) | |
print("Something is happening after the function is called.") | |
return wrapper |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let print_list f lst = | |
let rec print_elements = function | |
| [] -> () | |
| h::t -> f h; print_string "\n"; print_elements t | |
in | |
print_string ""; | |
print_elements lst; | |
print_string "";; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pandas as pd | |
df = pd.DataFrame({ | |
"timestamp": pd.date_range("now", periods=6), | |
"value": [1.005, 1.015, 1.020, 1.010, 1.000, 1.015], | |
"symbol": ['EUR/USD']*6, | |
"exchange": ['OTC']*6, | |
"description": ['EURUSD']*6 | |
}) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@font-size: 12px; | |
html, body, .tree-view, .tab-bar .tab { | |
font-size: @font-size; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var stream = require('stream'); | |
var util = require('util'); | |
const fs = require('fs'); | |
var Transform = stream.Transform; | |
function Upper(options) { | |
if (!(this instanceof Upper)) { | |
return new Upper(options); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const fs = require('fs'); | |
const localFilename1 = 'input.txt'; | |
const localFilename2 = 'output.txt'; | |
let rs = fs.createReadStream(localFilename1); | |
let ws = fs.createWriteStream(localFilename2); | |
rs.pipe(ws); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let translation = {'a': 'apa', 'b': 'beta'} | |
_.reduce({ 'a': 1, 'b': 2, 'c': 1 }, function(result, value, key) { | |
if(translation[key]) result[translation[key]] = value; | |
return result; | |
}, {}); | |
// {apa: 1, beta: 2} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//------------------------------------------------------- | |
/* data:csv | |
NAME,AGE,PHONE,CITY | |
Daffy Duck,24,08-123987,Stockholm | |
Bugs Bunny,22,08-987123,Copenhagen | |
Bunny Duck,31,08-719823,Paris | |
*/ | |
const stream = require('stream'); | |
const fs = require('fs'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const crypto = require('crypto') | |
const _ = require('lodash'); | |
let translation = {'name': 'symbol', 'age': 'age', 'phone': 'mobile'}; | |
let keys = _.keys(translation); | |
let string = keys.join(':'); | |
let hash = crypto.createHash('md5').update('string').digest("hex"); | |
console.log(string + " == > " + hash); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// Parse string to a format | |
// | |
const _ = require('lodash'); | |
// Try parse to Date | |
function tryParseDate(obj) { | |
let d = Date.parse(obj); | |
if (_.isNaN(d)) { | |
return {type: 'string', value: obj}; |
OlderNewer