Skip to content

Instantly share code, notes, and snippets.

View Gricha's full-sized avatar
🦀

Greg Pstrucha Gricha

🦀
View GitHub Profile
@Gricha
Gricha / Compact SmartLog
Created July 9, 2019 18:24
Git Smartlog
[alias]
smartlog = log --graph --pretty=format:'%C(dim white)(%h)%Creset %C(bold white)%s%Creset %C(bold magenta)%d%Creset%n %C(bold cyan)%an%Creset %C(blue)(%ae)%Creset %C(dim blue)%ci %Creset%n'
sl = !git smartlog
// Set globally
$ git config --global alias.smartlog "log --graph --pretty=format:'%C(dim white)(%h)%Creset %C(bold white)%s%Creset %C(bold magenta)%d%Creset%n %C(bold cyan)%an%Creset %C(blue)(%ae)%Creset %C(dim blue)%ci %Creset%n'"
$ git config --global alias.sl '!git smartlog'
@Gricha
Gricha / timestamp_from_string.rs
Created December 11, 2017 02:39
Timestamp from String
use std::fmt;
use serde::de;
use chrono::{DateTime, Utc, FixedOffset};
use chrono::offset::{LocalResult, TimeZone};
pub fn deserialize<'de, D>(d: D) -> Result<DateTime<Utc>, D::Error>
where D: de::Deserializer<'de>
{
Ok(try!(d.deserialize_i64(SecondsTimestampVisitor).map(|dt| dt.with_timezone(&Utc))))
import json
import googlemaps
import os
import sqlite3
from datetime import datetime
def extractDurationInTrafficFromResponse(response):
return response[0]['legs'][0]['duration_in_traffic']
{
"api_key":"Google Maps API Key for Directions",
"home": [
37.743658,
-119.599653
],
"work": [
37.481642,
-122.155606
]
import json
import googlemaps
from datetime import datetime
def extractDurationInTrafficFromResponse(response):
return response[0]['legs'][0]['duration_in_traffic']
def timesBetweenPoints(client, origin, destination):
best_guess_response = client.directions(origin,
destination,
@Gricha
Gricha / charter.json
Created August 28, 2014 10:55
My charter for Orisi
{
"version": "2",
"org_fee": "0.00006",
"org_address": "15PAcEwJQdH9JVti9w4q8vtMXZhW36JCm9",
"nodes": [
{
"pubkey": "03429116ecdd384757219a37e62a5154236eb334faafae8f910fbb9e015f695e0a",
"address": "1BzHARiQTgxYWq8YFDVnnAFLxgpYvirrdf",
"fee": "0.00003"
}
import uuid # from http://zesty.ca/python/uuid.html
import sys
import base64
def fetch_code(custom_string="CODE_'):
"""
takes an optional argument, a string to be put at the beginning of a code,
so the code will look like that: