Skip to content

Instantly share code, notes, and snippets.

Avatar
💜

Dmitriy (Dima) Rozhkov nLight

💜
View GitHub Profile
View better-hash-function.js
function hash(string) {
let index = 0;
for(let i = 0; i < string.length; i++) {
index += string.charCodeAt(i) * i;
}
return index % _size;
}
@nLight
nLight / stream.js
Last active Aug 3, 2018
Mesos stream replay server
View stream.js
const http = require('http')
const port = 3000
var fs = require('fs');
const requestHandler = (request, response) => {
console.log("Connected")
response.setHeader("Access-Control-Allow-Origin", "*")
response.setHeader("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept")
View source-unmap.js
var sourceMap = require('source-map');
var https = require('https');
var fs = require('fs');
var args = process.argv.slice(2);
if(args.length === 0) {
console.log("Usage: node index.js https://url.to/script.js:<line>:<column>");
return;
}
View .ssh-config
Host ssh-proxy
HostName proxy.example.com
User ubuntu
IdentityFile ~/.ssh/keys.pem
Host !ssh-proxy *
ProxyCommand ssh -q -W %h:%p ssh-proxy
ForwardAgent yes
@nLight
nLight / README.md
Last active Nov 21, 2015
GoPro Timer Proof of Concept
View README.md
View keybase.md

Keybase proof

I hereby claim:

  • I am nlight on github.
  • I am nlight (https://keybase.io/nlight) on keybase.
  • I have a public key whose fingerprint is 8FED C304 4FB5 D7B2 DD66 4A50 66CC 39C2 2061 3D8F

To claim this, I am signing this object:

View .bashrc
# Git
## Git undo
alias gundo="git reset HEAD~1"
## Resolve conflicts
alias conflicts='git status -s | grep -e "^\(DD\|AU\|UD\|UA\|DU\|AA\|UU\)" | cut -d " " -f2'
alias resolve='conflicts | xargs subl'
alias cadd='conflicts | xargs git add'
## WIP
View valvy.zsh-theme
# ZSH Theme - Preview: http://cl.ly/350F0F0k1M2y3A2i3p1S
PROMPT='%{$fg_bold[green]%}λ%{$reset_color%} %~/ $(git_prompt_info)%{$reset_color%}'
ZSH_THEME_GIT_PROMPT_PREFIX="%{$fg[green]%}"
ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%} "
@nLight
nLight / redis_set.rb
Created May 29, 2014
Ruby array-like wrapper for redis sets.
View redis_set.rb
require 'forwardable'
class RedisSet
extend Forwardable
def_delegators :to_ary, :first, :push, :shift, :size, :each, :map
def initialize(redis, key)
@redis = redis
@key = key
@nLight
nLight / index.html
Created May 9, 2014
Functional lenses in React.js with DrBoolean/lenses
View index.html
<!DOCTYPE html>
<html>
<head>
<title>React JS Lenses</title>
<script src="react-with-addons.min.js"></script>
<script src="JSXTransformer.js"></script>
<!-- https://github.com/DrBoolean/lenses/blob/master/dist/lenses.browser.js -->
<script src="lenses.browser.js"></script>
<!-- https://github.com/DrBoolean/pointfree-fantasy/blob/master/dist/pointfree.browser.js -->