Skip to content

Instantly share code, notes, and snippets.

View johnryan1982's full-sized avatar

John Ryan johnryan1982

View GitHub Profile
@johnryan1982
johnryan1982 / JS console SQL generation
Created July 5, 2012 17:35
Quick way to generate multiple SQL INSERT statements etc. using a browser's console
str = '';
for(var i=0; i<1000; i++){
str += "INSERT INTO VALUES ("+i+1000+")...;";
}
document.getElementsByTagName('body')[0].innerHTML = "<textarea>"+str+"</textarea>";
@johnryan1982
johnryan1982 / JS object iterator
Created July 12, 2012 22:30
Quick and dirty JS Object iterator
function iterate( data )
{
if( typeof data === typeof {} )
{
for( i in data )
{
if( data.hasOwnProperty( i ) )
{
console.log( i, data[i] );
iterate( data[i] );
@johnryan1982
johnryan1982 / JS wait
Created July 13, 2012 19:51
JS wait functionality
// credit to Sean McManus
// from http://www.sean.co.uk/a/webdesign/javascriptdelay.shtm
function wait( ms ) {
ms += new Date().getTime();
while ( new Date() < ms ){}
}
@johnryan1982
johnryan1982 / gist:d9cca2601f4f8a5e40fd
Created September 29, 2014 10:16
css: truncate text ("some text here...")
.truncate {
width: 50px;
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
}
@johnryan1982
johnryan1982 / securely remove file
Created January 11, 2015 14:36
Securely remove files on a Mac
srm -m [file]
@johnryan1982
johnryan1982 / date-value.csv
Created October 22, 2015 17:16
date-value.csv
date value
1988-01-01 12681
1988-01-02 13264
1988-01-03 13953
1988-01-04 13921
1988-01-05 13932
1988-01-06 13157
1988-01-07 11159
1988-01-08 11631
1988-01-09 12045
@johnryan1982
johnryan1982 / data-1000.csv
Created October 23, 2015 10:14
date-price-volume-value
date price volume value
23-Oct-15 11:02 11.76 34 399.84
23-Oct-15 11:01 9.68 233 2255.44
23-Oct-15 11:00 14.75 942 13894.50
23-Oct-15 10:59 12.37 271 3352.27
23-Oct-15 10:58 9.49 116 1100.84
23-Oct-15 10:57 10.05 459 4612.95
23-Oct-15 10:56 12.51 877 10971.27
23-Oct-15 10:55 14.18 148 2098.64
23-Oct-15 10:54 13.45 212 2851.40
body {
font: 10px sans-serif;
}
.axis line,
.axis path {
fill: none;
stroke: #000;
shape-rendering: crispEdges;
}
.axis text {
@johnryan1982
johnryan1982 / example.sh
Created September 19, 2016 11:27
create temporary empty files on multiple systems
/// Linux
fallocate -l 10G temp_10GB_file
/// Windows
fsutil file createnew temp_10GB_file 10000000000
/// Mac OS
mkfile -n 10g temp_10GB_file
@johnryan1982
johnryan1982 / wget.sh
Created August 4, 2018 09:11 — forked from crittermike/wget.sh
Download an entire website with wget, along with assets.
wget \
--recursive \ # Download the whole site.
--no-clobber \ # Don't overwrite existing files.
--page-requisites \ # Get all assets/elements (CSS/JS/images).
--adjust-extension \ # Save files with .html on the end.
--span-hosts \ # Include necessary assets from offsite as well.
--convert-links \ # Update links to still work in the static version.
--restrict-file-names=windows \ # Modify filenames to work in Windows as well.
--domains yoursite.com \ # Do not follow links outside this domain.
--no-parent \ # Don't follow links outside the directory you pass in.