Skip to content

Instantly share code, notes, and snippets.

View lgmkr's full-sized avatar
🏠
Working from home

Oleh Makarov lgmkr

🏠
Working from home
View GitHub Profile
@lgmkr
lgmkr / install-mit-schema-for-SICP.md
Created December 30, 2017 11:30 — forked from deepak/install-mit-schema-for-SICP.md
installing MIT-scheme for doing SICP

installing MIT Schema

The SICP page recommends MIT scheme,
so that is what we will use

to install it, on Apple OSX using Homebrew:

  brew tap x11
  brew cask install xquartz
@lgmkr
lgmkr / git-rebase.markdown
Created August 21, 2012 08:51 — forked from tmcgilchrist/git-rebase.markdown
Git rebase workflow

Checkout a new working branch

 git checkout -b <branchname>

Make Changes

 git add
 git commit -m "description of changes"

Sync with remote

@lgmkr
lgmkr / ts-basic-types.ts
Last active April 23, 2020 15:12
ts-in-nodejs
// primitive types
let isOk: boolean = true;
let greeting: string = "Hello";
let count: number = 5;
let fruits: string[] = ["banana", "apple"]; // Array<string>
let tuple: [string, number] = ["hi", 10]; // tuple[3] = 1 <- error
enum Fruits {
banana = "BANANA",
apple = "APPLE",
npm install --save-dev @babel/core @babel/preset-env
@lgmkr
lgmkr / index.js
Last active December 6, 2018 20:34
#!/usr/bin/env node
console.log('Hello world!')
var f = x => x * 10
f(100) //=> 1000
var f = x => console.log(x * 10)
f(100) //=> 1000
(x => console.log(x * 10))(10) //=> 100
(10)(x => console.log(x*10)) // Error
0x594A1057366D4Db941f90F0D8311e50CB64a9979
@lgmkr
lgmkr / count_words.py
Last active November 3, 2016 19:52
How to analyse text and count word frequencies in python
import re
import string
frequency = {}
document_text = open('test.txt', 'r')
text_string = document_text.read().lower()
match_pattern = re.findall(r'\b[a-z]{3,15}\b', text_string)
for word in match_pattern:
count = frequency.get(word,0)
module HashConverter
class << self
def to_underscore hash
convert hash, :underscore
end
def to_camel_case hash
convert hash, :camelize, :lower
end
def convert obj, *method
case obj
@lgmkr
lgmkr / gist:5357725
Created April 10, 2013 19:32
generate UUID in ruby
::uuid generates a v4 random UUID (Universally Unique IDentifier).
p SecureRandom.uuid #=> "2d931510-d99f-494a-8c67-87feb05e1594"
p SecureRandom.uuid #=> "bad85eb9-0713-4da7-8d36-07a8e4b00eab"
p SecureRandom.uuid #=> "62936e70-1815-439b-bf89-8492855a7e6b"
The version 4 UUID is purely random (except the version). It doesn’t contain meaningful information such as MAC address, time, etc.