Skip to content

Instantly share code, notes, and snippets.

View grigorkh's full-sized avatar

Grigør grigorkh

View GitHub Profile
function isPalindrome(str) {
str = str.replace(/\W/g, '').toLowerCase();
return (str == str.split('').reverse().join(''));
}
@grigorkh
grigorkh / response.json
Last active July 13, 2016 20:15
qr.eyme.io
Usage:
{
"GET": "https://qr.eyme.io/api/?url=http://goo.gl/9DhbLX"
}
Response Example:
{
"vendor":"Gago Inc.",
"model":"Aram",
"screen_to_lens_distance":0.041999999433755875,
@grigorkh
grigorkh / add.js
Created August 12, 2016 11:51 — forked from getify/add.js
an `add(..)` function that keeps going forever :)
function add() {
var sum = 0;
function add() {
for (var i=0; i<arguments.length; i++) {
sum += Number(arguments[i]);
}
return add;
}
add.valueOf = function valueOf(){
@grigorkh
grigorkh / class.js
Created August 28, 2016 09:36
Singleton ES6 class
let instance = null;
export class Cache{
constructor() {
if(!instance){
instance = this;
}
this.time = new Date()
@grigorkh
grigorkh / Singleton.js
Created August 28, 2016 09:47 — forked from you-think-you-are-special/Singleton.js
ES6 Singleton example. Use: import Singleton from 'Singleton'; let instance = Singleton.instance;
'use strict';
/**
* Created by Alexander Litvinov
* Email: alexander@codeordie.ru
* May be freely distributed under the MIT license
*/
let singleton = Symbol();
let singletonEnforcer = Symbol();
//two main tasks are 'gulp watch' and 'gulp build'
//dependencies:
var gulp = require('gulp');
//to use in conjunction with chrome plugin:
livereload = require('gulp-livereload');
//for css:
sass = require('gulp-sass'),
autoprefixer = require('gulp-autoprefixer'),
minifycss = reqwuire('gulp-minify-css'),
@grigorkh
grigorkh / ngx-lua.bash
Last active December 21, 2016 10:47
Script to compile nginx on ubuntu with lua support.
#!/bin/bash
#
# bash < <(curl -s https://gist.githubusercontent.com/grigorkh/17285401e6be1b7950f638dd58a8d0a3/raw/cbbd7fd2205e1aebdf79649b98d598e4344040c2/ngx-lua.bash)
set -x
cd /tmp
if ! test -d /usr/local/include/luajit-2.0; then
echo "Installing LuaJIT-2.0.4."
wget "http://luajit.org/download/LuaJIT-2.0.4.tar.gz"
#!/bin/bash
#
# bash < <(curl -s https://gist.githubusercontent.com/grigorkh/6fbab691f85f2ecd1bed0e2824316bef/raw/e3017e8b485f28e5d9119c77daf4f21717ccea2d/ngx-lua-redis.bash)
set -x
cd /tmp
echo "Installing LuaJIT-2.0.4."
wget "http://luajit.org/download/LuaJIT-2.0.4.tar.gz"
tar -xzvf LuaJIT-2.0.4.tar.gz
@grigorkh
grigorkh / letsencrypt_2017.md
Created January 22, 2017 14:38
How to setup Let's Encrypt for Nginx on Ubuntu 16.04 (including IPv6, HTTP/2 and A+ SLL rating)

How to setup Let's Encrypt for Nginx on Ubuntu 16.04 (including IPv6, HTTP/2 and A+ SLL rating)

There are two modes when you don't want Certbot to edit your configuration:

  • Standalone: replaces the webserver to respond to ACME challenges
  • Webroot: needs your webserver to serve challenges from a known folder.

Webroot is better because it doesn't need to replace Nginx (to bind to port 80) to renew certificates.

In the following, we're setting up mydomain.com to be served from /var/www/mydomain, and challenges will be served from /var/www/letsencrypt.

@grigorkh
grigorkh / gist:f23b208805d5751f7656bb1dcaa52b12
Created March 31, 2017 11:42 — forked from hayderimran7/gist:9246dd195f785cf4783d
How to solve "sudo: no tty present and no askpass program specified" when trying to run a shell from Jenkins
Running shell scripts that have contain sudo commands in them from jenkins might not run as expected. To fix this, follow along
Simple steps:
1. On ubuntu based systems, run " $ sudo visudo "
2. this will open /etc/sudoers file.
3. If your jenkins user is already in that file, then modify to look like this:
jenkins ALL=(ALL) NOPASSWD: ALL
4. save the file by doing Ctrl+O (dont save in tmp file. save in /etc/sudoers, confirm overwrite)
5. Exit by doing Ctrl+X
6. Relaunch your jenkins job