Skip to content

Instantly share code, notes, and snippets.

View vgarvardt's full-sized avatar

Vladimir Garvardt vgarvardt

View GitHub Profile
#!/usr/bin/env bash
set -e
token=$1
if [[ -z "${token}" ]]; then
echo "Pass an argument to a script to use as a search term"
exit 1
fi
$('.submit').click(function(){
var firstName = $('.first').val(),
lastName = $('.last').val(),
maidenName = $('.maiden').val(),
birthCity = $('.birth').val(),
subFirst = lastName.substring(0,3) + firstName.substring(0,2),
subLast = maidenName.substring(0,2) + birthCity.substring(0,3),
starWarsName = subFirst + ' ' + subLast;
$('.result').html(starWarsName.toLowerCase());
@vgarvardt
vgarvardt / css.css
Created December 21, 2015 09:36
Pure CSS Star Wars opening crawl @ http://codepen.io/yukulele/pen/KsCIi
#target{
position:absolute;
top:-3500px;
bottom:0;
left:0;
right:0;
overflow:hidden;
font-size:30px;
text-align:center;
font-family:sans-serif;
@vgarvardt
vgarvardt / css.css
Created December 21, 2015 09:33
Star Wars Toggle Icon Animation @ http://codepen.io/rss/pen/vIDKH
body{
background:#222;
padding: 100px;
font-size: 10px; /*increase me to scale toogle-icon*/
}
#nav-container{
position: absolute;
top: 50%;
left: 50%;
@vgarvardt
vgarvardt / unique_id_microtime.php
Created December 10, 2015 14:44
Generate unique IDs from microtime and calculate collisions
<?php
$iterations = 100000;
$orderNrLen = 6;
for ($secondsLen = 0; $secondsLen < 6; $secondsLen++) {
$numbers = [];
$collisions = 0;
for ($i = 0; $i < $iterations; $i++) {
if ($i % 1000 == 0) sleep(1);
@vgarvardt
vgarvardt / elapsed.go
Created May 25, 2015 16:23
Function elapsed time in golang from http://play.golang.org/p/U58I5eGXRY
package main
import (
"log"
"time"
)
func whenDone() func(format string, args ...interface{}) {
start := time.Now()
return func(format string, args ...interface{}) {
#!/bin/bash
echo "Select on option:"
echo "1) Set up new PoPToP server AND create one user"
echo "2) Create additional users"
read x
if test $x -eq 1; then
echo "Enter username that you want to create (eg. client1 or john):"
read u
echo "Specify password that you want the server to use:"
read p
@vgarvardt
vgarvardt / prs.py
Created December 9, 2014 09:33
List all PRs
#!/usr/bin/env python
"""git pull-request
Automatically check out github pull requests into their own branch.
Usage:
git pull-request <OPTIONS> [<pull request number>]
@vgarvardt
vgarvardt / fabfile.py
Created October 16, 2014 12:19
Fabric task to display currently installed packages and latest versions from pypi
# -*- coding:utf-8 -*-
import pip
import xmlrpclib
from fabric.api import task
@task
def pipversions():
"""
Check installed packeges updates on pypi
@vgarvardt
vgarvardt / crawler.go
Last active August 29, 2015 14:03
Simple crawler in Go
// originally found @ http://venkat.io/posts/concurrent-crawling/
package main
//The builtins are limited. Making a lot of imports necessary
import ("sync"
"net/http"
"regexp"
"io/ioutil"
"os"
"bytes"