Skip to content

Instantly share code, notes, and snippets.

View amok's full-sized avatar

Max Kolodezhnyi amok

View GitHub Profile
const DIRECTION_DOWN = -1;
const DIRECTION_NONE = 0;
const DIRECTION_UP = 1;
function HardwareElevator() {}
HardwareElevator.prototype = {
moveUp: function() { console.log("up") },
moveDown: function() { console.log("down") },
stopAndOpenDoors: function() { console.log("stop and open") },
@amok
amok / flatten.js
Created October 10, 2017 22:40
js array flatten
const flatten = a => a.reduce((memo, value) => {
return Array.isArray(value) ?
[...memo, ...flatten(value)] :
[...memo, value]
}, [])
FROM node:8-alpine
RUN apk add --update curl && \
rm -rf /var/cache/apk/*
# Add the patch fix
# see https://github.com/sass/node-sass/issues/2031 https://github.com/esnme/ultrajson/issues/254#issuecomment-314862445
RUN curl -o /lib/stack-fix.c "https://gist.githubusercontent.com/amok/daa16ae28fd10481ba1eca50c855d45e/raw/a087786e9f218afd6d1397eaa82ee44fa81eb660/stack-fix.c"
# Prepare the libraries packages
@amok
amok / ast vs rpn.js
Last active August 29, 2015 14:03 — forked from koorchik/ast vs rpn.js
/*
There is an AST (Abstract syntax tree) in JSON format.
AST represents Excel spreadsheet formula.
Is it possible in JavaScript to make RPN (Reverse Polish Notation) faster than AST?
AST evaluation is recusive and RPN evaluation is iterative.
But in any case, AST evaluation is faster despite recursion.
I guess that the main problem is in using dynamic js arrays to emulate stack.
Would RPN win if it was written in C/C++?
#!/bin/bash
# Author: Alexander Schulz
VHOSTEN="/etc/nginx/sites-enabled/"
if [[ $1 == "-h" ]] || [[ $1 == "--help" ]]
then
echo 'Usage: n2dissite VHOST'
echo 'Disables Nginxs virtualhost VHOST.'
@amok
amok / psmouse-alps-install.sh
Last active December 11, 2015 19:08
Install psmouse alps drivers
#!/bin/sh
if [ "$(id -u)" != "0" ]; then
echo "$0 must be run as root"
exit 1
fi
echo 'Internet required for this to work'
cd ~
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>HTML5 boilerplate</title>
<link rel="stylesheet" href="css/style.css">
<script src="js/main.js"></script>
</head>
<body>
<h1>HTML5 boilerplate</h1>
@amok
amok / MyUbuntuRequiredApps.sh
Last active October 10, 2015 12:08
local-lib-autosetup.sh
#!/bin/sh
sudo add-apt-repository -y "deb http://archive.canonical.com/ $(lsb_release -sc) partner"; # skype
sudo add-apt-repository -y ppa:indicator-multiload/stable-daily # system monitor applet
apt-get update;
apt-get -y upgrade;
apt-get -y install build-essential linux-headers-generic linux-headers-`uname -r`;
apt-get install -y curl;
@amok
amok / .bashrc
Last active October 10, 2015 12:08
My .bashrc file
if [ -t 1 ];
then
setfont /usr/share/consolefonts/CyrSlav-Terminus14.psf.gz &> /dev/null
fi
PS1='\[\033[01;32m\]\u\[\033[01;34m\]\[\033[0;37m\]@\[\033[01;31m\]\h\[\033[01;34m\]\w/\[\033[0;37m\]\[\033[1;33m\]$(__git_ps1 "[%s]")\[\033[0;37m\]\$ \[\033[0m\]'
function kill-voracious() {
process=(`ps -u $USER -o pid,comm --sort %cpu | tail -n 1`);
@amok
amok / Atheros-AR8161-install.sh
Last active October 10, 2015 07:18 — forked from chrisl8888/Atheros-AR8161-install.sh
How do I install drivers for the Atheros AR8161 Ethernet controller?
#!/bin/bash
# From: http://askubuntu.com/questions/165192/how-do-i-install-drivers-for-the-atheros-ar8161-ethernet-controller
# must be runned as root
if [ "$(id -u)" != "0" ]; then
echo "$0 must be run as root"
exit 1
fi
echo 'Rebuilding drivers for Atheros ar8161 Ethernet Controller...'