Skip to content

Instantly share code, notes, and snippets.

Andrew Zakordonets azakordonets

Block or report user

Report or block azakordonets

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@azakordonets
azakordonets / ohMyZshHistoryCleanUp.regex
Created Aug 29, 2016
This regular expression allows to remove from .zhs_history all the "trashy" commands that are used commonly and reduce the size of the file
View ohMyZshHistoryCleanUp.regex
: \d+:0;(gd|gst|gaa|ga|gc|irb|git reset|git stash|newzsh|glg|gb|git push|git init|grm|gl|mc|top|git rebase|ember|rake|rackup|git rm|sensors|rails s|tree|ls|ember install|rubocop|reboot|pry|gitg|gitk|man|unity|bower install|npm install|bundle install|bundle update|git pull|node|jekyll|kill|bin\/console|tmux|la|cd ~/code|nvm|fm|ruby).*\n
View run_es6_code_in_sublime.js
{
"cmd": ["babel-node", "$file"],
"selector": "source.js",
"path": "/usr/local/bin:$PATH", // ENV setting for mac users
"quiet": true // get rid of annoying `[Finished in %fs]`
}
View iban.json
{
"values": [
{
"country": "Albania",
"length": "28",
"code": "AL",
"format": "AL2!n8!n16!c"
},
{
"country": "Andorra",
View csv_to_json.py
import csv
import json
csvfile = open('test.csv', 'r')
jsonfile = open('file.json', 'w')
def lookahead(iterable):
"""Pass through all values from the given iterable, augmented by the
information if there are more values to come after the current one
(True), or if it is the last value (False).
View dateDifference.js
const dateDiffInMillis = (date1, date2) =>
Math.abs(date2.getTime() - date1.getTime());
const dayDifferenceInSeconds = (date1, date2) =>
Math.round(dateDiffInMillis(date1, date2) / 1000);
const minuteDifferenceBetweenDates = (date1, date2) =>
Math.round(dayDifferenceInSeconds(date1, date2) / 60);
View milliseconds_to_seconds_formatted.java
long startTime = System.nanoTime();
method();
long stopTime = System.nanoTime();
long millis = stopTime - startTime;
public String getDurationFormattedString(long startTime, long stopTime) {
final long nanosDifference = stopTime - startTime;
return String.format("%02d min, %02d sec %02d millis",
TimeUnit.NANOSECONDS.toMinutes(nanosDifference),
TimeUnit.NANOSECONDS.toSeconds(nanosDifference) -
@azakordonets
azakordonets / formatJSON.js
Last active Jan 27, 2016
If you want nicely to display JSON in your webpage then this is a nice solution for you . http://jsfiddle.net/KJQ9K/554/
View formatJSON.js
function output(inp) {
document.body.appendChild(document.createElement('pre')).innerHTML = inp;
}
function syntaxHighlight(json) {
json = json.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;');
return json.replace(/("(\\u[a-zA-Z0-9]{4}|\\[^u]|[^\\"])*"(\s*:)?|\b(true|false|null)\b|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?)/g, function (match) {
var cls = 'number';
if (/^"/.test(match)) {
if (/:$/.test(match)) {
@azakordonets
azakordonets / formatString.js
Created Jan 22, 2016
This is a nice formatter for strings in javascript
View formatString.js
+String.prototype.format = function (placeholders) {
+ var s = this;
+ for (var propertyName in placeholders) {
+ var re = new RegExp('{' + propertyName + '}', 'gm');
+ s = s.replace(re, placeholders[propertyName]);
+ }
+ return s;
+};
console.log("Hi my name is ${name} and i'm {$age} years old".format({name: "Andrew", age: "30"}))
@azakordonets
azakordonets / gist:8700e11e8ecf1b247ec0
Created Jan 12, 2016 — forked from posaunehm/gist:8300175
call pandoc for JavaScript-Garden. Before running this script - download zip archive, go to doc-> {language} and then run it
View gist:8700e11e8ecf1b247ec0
pandoc intro/index.md object/general.md object/prototype.md object/hasownproperty.md object/forinloop.md function/general.md function/this.md function/closures.md function/arguments.md function/constructors.md function/scopes.md array/general.md array/constructor.md types/equality.md types/typeof.md types/instanceof.md types/casting.md core/eval.md core/undefined.md core/semicolon.md core/delete.md other/timeouts.md -o Javascript-Garden.epub
@azakordonets
azakordonets / ArrayMaxMin.js
Created Dec 28, 2015
Get Max or Min from Javascript array
View ArrayMaxMin.js
function getArrayMaxValue(arr) {
return Math.max.apply(null, arr);
}
function getArrayMinValue(arr) {
return Math.min.apply(null, arr);
}
You can’t perform that action at this time.