Skip to content

Instantly share code, notes, and snippets.

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

Kasun Vithanage kasvith

🏠
Working from home
View GitHub Profile

Mini validations lib

Section

defmodule Dataset do
@sasa1977
sasa1977 / sql_parser.exs
Created October 13, 2019 08:56
Basic SQL parser developed at WebCamp Zagreb, 2019
defmodule SqlParser do
def run() do
input = "select col1 from (
select col2, col3 from (
select col4, col5, col6 from some_table
)
)
"
IO.puts("input: #{inspect(input)}\n")
IO.inspect(parse(input))
@jalbam
jalbam / performance.now-polyfill.js
Last active November 27, 2022 06:27
window.performance.now polyfill
'use strict';
// @license http://opensource.org/licenses/MIT
// copyright Paul Irish 2015
// Added code by Aaron Levine from: https://gist.github.com/Aldlevine/3f716f447322edbb3671
// Some modifications by Joan Alba Maldonado.
// as Safari 6 doesn't have support for NavigationTiming, we use a Date.now() timestamp for relative values
// if you want values similar to what you'd get with real perf.now, place this towards the head of the page
// but in reality, you're just getting the delta between now() calls, so it's not terribly important where it's placed
// Gist: https://gist.github.com/jalbam/cc805ac3cfe14004ecdf323159ecf40e
@akilawickey
akilawickey / app.js
Last active March 11, 2018 08:40
Adding a ssl on nginx with nodejs application
var express = require('express');
var path = require('path');
var favicon = require('serve-favicon');
var logger = require('morgan');
var cookieParser = require('cookie-parser');
var bodyParser = require('body-parser');
var exphbs = require('express-handlebars');
var router = express.Router();
var index = require('./routes/index');
@andrewhao
andrewhao / game.ex
Last active August 7, 2023 21:37
Dynamic Supervisors in Elixir
defmodule Game do
use GenServer
def init(game_id) do
{:ok, %{game_id: game_id}}
end
def start_link(game_id) do
GenServer.start_link(__MODULE__, game_id, name: {:global, "game:#{game_id}"})
end
@GMMan
GMMan / ubuntu-gl502vs.md
Last active July 22, 2020 15:30
Problems and Solutions for Ubuntu 16.04 LTS on ASUS ROG GL502VS Laptop

Problems and Solutions for Ubuntu 16.04 LTS on ASUS ROG GL502VS Laptop

NVIDIA Graphics

Nouveau does not appear to support Pascal cards right now, so you should use the proprietary NVIDIA driver, available from the Additional Drivers applet.

Panel Dithering

@slavafomin
slavafomin / nodejs-custom-es6-errors.md
Last active March 9, 2024 12:03
Custom ES6 errors in Node.js

Here's how you could create custom error classes in Node.js using latest ES6 / ES2015 syntax.

I've tried to make it as lean and unobtrusive as possible.

Defining our own base class for errors

errors/AppError.js

@mastef
mastef / isexist_vs_isnotexist.go
Created February 4, 2016 08:30
os.IsExist(err) vs os.IsNotExist(err)
/*
Watch out, os.IsExist(err) != !os.IsNotExist(err)
They are error checkers, so use them only when err != nil, and you want to handle
specific errors in a different way!
Their main purpose is to wrap around OS error messages for you, so you don't have to test
for Windows/Unix/Mobile/other OS error messages for "file exists/directory exists" and
"file does not exist/directory does not exist"
@parmentf
parmentf / GitCommitEmoji.md
Last active April 24, 2024 13:34
Git Commit message Emoji