Skip to content

Instantly share code, notes, and snippets.

@nopium
nopium / gist:5316199
Created April 5, 2013 02:44
detect console open
function isCosoleOpen() {
console.profile();
console.profileEnd();
if(console.clear) { console.clear() };
return console.profiles.length > 0;
}
#!/bin/sh
DB=YOUR_DB_NAME
USER=DB_USER
PASSWORD=DB_PASS
BACKUP_DIR=~/db_backups/$DB
[ -d "$BACKUP_DIR" ] || mkdir -p "$BACKUP_DIR"
setBackground() {
osascript -e "tell application \"iTerm\"
set myterm to (current terminal)
tell myterm
set mysession to (current session)
tell mysession
set background color to $1
end tell
end tell
end tell"
@nopium
nopium / .htaccess
Created June 5, 2016 16:18 — forked from ScottPhillips/.htaccess
Common .htaccess Redirects
#301 Redirects for .htaccess
#Redirect a single page:
Redirect 301 /pagename.php http://www.domain.com/pagename.html
#Redirect an entire site:
Redirect 301 / http://www.domain.com/
#Redirect an entire site to a sub folder
Redirect 301 / http://www.domain.com/subfolder/
Directives
==========
Directive calls controller
-------------------------
app.controller("AppCtrl", function($scope) {
$scope.func = function() {
alert("Controller's function published on scope");
}
}
@nopium
nopium / min-char-rnn.py
Created February 10, 2017 07:08 — forked from karpathy/min-char-rnn.py
Minimal character-level language model with a Vanilla Recurrent Neural Network, in Python/numpy
"""
Minimal character-level Vanilla RNN model. Written by Andrej Karpathy (@karpathy)
BSD License
"""
import numpy as np
# data I/O
data = open('input.txt', 'r').read() # should be simple plain text file
chars = list(set(data))
data_size, vocab_size = len(data), len(chars)
@nopium
nopium / blip
Created February 8, 2020 12:01
/*!
* jQuery JavaScript Library v1.4.1
* http://jquery.com/
*
* Copyright 2010, John Resig
* Dual licensed under the MIT or GPL Version 2 licenses.
* http://jquery.org/license
*
* Includes Sizzle.js
* http://sizzlejs.com/
var els = document.getElementsByClassName("yt-simple-endpoint");
var links = {};
for (var e in els ) {
if( els[e].href && els[e].href.indexOf('watch')!=-1 ) {
var link = els[e].href.split('&list')[0];
links[link] = link;
}
}
for(var l in Object.keys(links)) {
console.log(l);
// lighthouse-batch -s -p "--perf --quiet" -f urls-boats.txt -o report-lvb
var parsedJSON = require('./report-lvb/summary.json');
var worst = [];
var seventies = [];
var eighties = [];
var nineties = [];
console.log('Total: '+parsedJSON.length);
for (var r in parsedJSON) {
var row = parsedJSON[r];
// Cross-broswer implementation of text ranges and selections
// documentation: http://bililite.com/blog/2011/01/17/cross-browser-text-ranges-and-selections/
// Version: 2.6
// Copyright (c) 2013 Daniel Wachsstock
// MIT license:
// Permission is hereby granted, free of charge, to any person
// obtaining a copy of this software and associated documentation
// files (the "Software"), to deal in the Software without
// restriction, including without limitation the rights to use,
// copy, modify, merge, publish, distribute, sublicense, and/or sell