Skip to content

Instantly share code, notes, and snippets.

View n0m4dz's full-sized avatar

Tseegii Tselmeg n0m4dz

View GitHub Profile
@n0m4dz
n0m4dz / mocha-guide-to-testing.js
Created September 1, 2016 23:45 — forked from samwize/mocha-guide-to-testing.js
Explain Mocha's testing framework - describe(), it() and before()/etc hooks
// # Mocha Guide to Testing
// Objective is to explain describe(), it(), and before()/etc hooks
// 1. `describe()` is merely for grouping, which you can nest as deep
// 2. `it()` is a test case
// 3. `before()`, `beforeEach()`, `after()`, `afterEach()` are hooks to run
// before/after first/each it() or describe().
//
// Which means, `before()` is run before first it()/describe()
@n0m4dz
n0m4dz / lopmonhoc.js.jsx
Created August 30, 2016 12:59 — forked from revskill10/lopmonhoc.js.jsx
Integrate Datatable with React.js
/** @jsx React.DOM */
var LopMonHoc = React.createClass({
getInitialState: function(){
return {data: []}
},
loadData: function(){
$.ajax({
url: '/daotao/lops',
success: function(data){
@n0m4dz
n0m4dz / nginx.conf
Created August 24, 2016 11:13 — forked from turtlesoupy/nginx.conf
node.js upstream nginx config
http {
proxy_cache_path /var/cache/nginx levels=1:2 keys_zone=one:8m max_size=3000m inactive=600m;
proxy_temp_path /var/tmp;
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
gzip on;
gzip_comp_level 6;
@n0m4dz
n0m4dz / react-with-routing.js
Created August 8, 2016 11:30 — forked from jaysoo/react-with-routing.js
React structure with routing
/*
* This file contains JS modules for a React app using react-router and redux.
* Each module should be in its own separate file, but for the purposes of
* this gist, I've inlined them all.
*/
/* app/index.js */
import React from 'react'
import { Router, browserHistory } from 'react-router'
@n0m4dz
n0m4dz / README.md
Created July 14, 2016 12:13 — forked from denji/README.md
Remove settings and cli-links WebStorm; PhpStorm, PyCharm, RubyMine, AppCode, CLion, IntelliJ, 0xDBE10, Rider (OS X & macOS)

Quick uninstall JetBrains settings:

curl -sL https://gist.github.com/denji/9731967/raw/jetbrains-uninstall.sh | bash -s

Quick backup JetBrains settings:

curl -sL https://gist.github.com/denji/9731967/raw/jetbrains-backup.sh | bash -s
@n0m4dz
n0m4dz / chruby_ruby-build.sh
Created May 20, 2016 14:30 — forked from havenwood/chruby_ruby-build.sh
On Debian, Ubuntu, or Mint: install Ruby with chruby and ruby-build
# Install apt-get packages:
sudo apt-get install build-essential openssl libreadline6 libreadline6-dev curl git-core zlib1g zlib1g-dev libssl-dev libyaml-dev libsqlite3-dev sqlite3 libxml2-dev libxslt-dev autoconf libc6-dev ncurses-dev automake libtool bison subversion pkg-config
# Install chruby:
cd
wget https://github.com/downloads/postmodern/chruby/chruby-0.2.3.tar.gz
tar -xzvf chruby-0.2.3.tar.gz
cd chruby-0.2.3
sudo make install
@n0m4dz
n0m4dz / leaflet_numbered_markers.css
Created April 14, 2016 01:08 — forked from comp615/leaflet_numbered_markers.css
Numbered Markers in Leaflet (JS Mapping)
.leaflet-div-icon {
background: transparent;
border: none;
}
.leaflet-marker-icon .number{
position: relative;
top: -37px;
font-size: 12px;
width: 25px;
@n0m4dz
n0m4dz / findLocalItems.js
Last active February 20, 2023 18:18 — forked from ungoldman/findLocalItems.js
how to filter keys from localStorage with a regex
// returns an array of localStorage items in key/value pairs based on a query parameter
// returns all localStorage items if query isn't specified
// query can be a string or a RegExp object
function findLocalItems (query) {
var i, results = [];
for (i in localStorage) {
if (localStorage.hasOwnProperty(i)) {
if (i.match(query) || (!query && typeof i === 'string')) {
value = JSON.parse(localStorage.getItem(i));
<html>
<head>
<script type="text/javascript">
window.PrintView = function(elem)
{
var content = document.getElementById(elem).innerHTML;
var mywindow = window.open('', 'my div', 'height=600,width=900');
mywindow.document.write('<html><head><title>my div</title>');
mywindow.document.write('</head><body >');
mywindow.document.write(content);
@n0m4dz
n0m4dz / Database.php
Last active September 29, 2022 11:27
PHP PDO database CRUD class
<?php
class Database extends PDO
{
public function __construct($DB_TYPE, $DB_HOST, $DB_NAME, $DB_USER, $DB_PASS)
{
parent::__construct($DB_TYPE.':host='.$DB_HOST.';dbname='.$DB_NAME, $DB_USER, $DB_PASS);
}