Skip to content

Instantly share code, notes, and snippets.

@vladvelici
vladvelici / elif.bytecode
Last active August 14, 2017 11:33
Gist for the elif Quora answer
1 0 LOAD_CONST 0 (5)
2 STORE_NAME 0 (x)
2 4 LOAD_NAME 0 (x)
6 LOAD_CONST 0 (5)
8 COMPARE_OP 0 (<)
10 POP_JUMP_IF_FALSE 22
3 12 LOAD_NAME 1 (print)
14 LOAD_CONST 1 ('x less than 5')
@vladvelici
vladvelici / less-than-syntax-highlight.ts
Created February 26, 2016 12:55
atom-typescript `<` syntax highlight
var i : number = 9;
/** Simple less then checks */
var v = i < 5+5;
var v = i <5+5;
var v = i<5+5;
var v=i<5+5;
/** If statement no space before "<" */
if (i<5+5) { console.log("something"); }
@vladvelici
vladvelici / valid-example.go
Last active August 29, 2015 14:12
This is an example usage of the github.com/vladvelici/valid package.
// Example code for a simple custom validator using github.com/vladvelici/valid
//
// This program outputs:
//
// $ ./valid-example hello
// Validation result: 2 errors.
// 1. Not "example" (case-insensitive).
// 2. Not exactly "example".
//
// $ ./valid-example example
@vladvelici
vladvelici / gen.go
Last active August 29, 2015 14:07
Random word picker from dictionary file.
// This tool gets a list of random words form a given dictionary.
// The dictionary must be specified using the -dict flag.
// The number of words can be specified using the -n flag.
// The number of words is,
// by default, 10 or, if the dictionary is smaller, half its size.
package main
import (
"bufio"
"flag"
@vladvelici
vladvelici / git
Created November 24, 2013 19:36
git hackatalk
why git?
- remove the goddamn folders like final, final_final, ultimate, submit etc
- keep versioning in a sane order
- branch and experiment (feel free to code drunk)
<!DOCTYPE html>
<html>
<head>
<title>video test</title>
</head>
<body>
<video width='500' height='500' id='v'></video>
<canvas width='500' height='500' id='c'></canvas>
<script type="text/javascript">
@vladvelici
vladvelici / hello.py
Created October 23, 2012 21:43
comp1203 lab preparation - python hello world
#!/usr/bin/env python
# I really tested this file. it works. :)
print "Hello world!"
# :)
@vladvelici
vladvelici / barcode.rb
Created July 28, 2012 02:57
A convertion from GTIN/EAN/UCC 13, UPC-12/UPCA/GTIN12, EAN/UCC 8/GTIN-8 or UPCE to GTIN-14 for simple storage and lookup
# (C) 2012 Vlad Velici
# Released under MIT licence. See licence.txt
# ====
# USAGE:
#
# gtin14 = Barcode::standardize "123456"
# --- OR ---
# bc = Barcode.new "123456"
# bc.gtin [the given code in GTIN-14 format]
# bc.original_type [:ean13|:ean8|:gtin|:upca|:upce] [the type of the input barcode]