Skip to content

Instantly share code, notes, and snippets.

🌮Tacos
☑️Ricotta salata
☑️Cotija
☑️Monterey Jack
☑️Swiss
☑️Sour cream
☑️Tomato
☑️Red onion
☑️Green chilli
@tsnoad
tsnoad / gist:93220703e6fa8a7ebd1d3e6d8754503f
Created May 18, 2017 01:37
Cura gcode to x3g conversion
f=T_coolingfan.gcode && cat $f | sed 's/M109 S/M104 S/g' | sed 's/M190 /M109 /g' | /Users/tsnoad/Things/GPX/gpx -s > ${f%.*}.x3g
@tsnoad
tsnoad / gist:270ac205b9147b563afdacac09c7dbe8
Created May 18, 2017 01:37
Cura gcode to x3g conversion
f=T_coolingfan.gcode && cat $f | sed 's/M109 S/M104 S/g' | sed 's/M190 /M109 /g' | /Users/tsnoad/Things/GPX/gpx -s > ${f%.*}.x3g
   wget http://tiles.kerbalmaps.com/mun/sat/2/0/3.png -O 0000.png \
&& wget http://tiles.kerbalmaps.com/mun/sat/2/1/3.png -O 0001.png \
&& wget http://tiles.kerbalmaps.com/mun/sat/2/2/3.png -O 0002.png \
&& wget http://tiles.kerbalmaps.com/mun/sat/2/3/3.png -O 0003.png \
&& wget http://tiles.kerbalmaps.com/mun/sat/2/4/3.png -O 0004.png \
&& wget http://tiles.kerbalmaps.com/mun/sat/2/5/3.png -O 0005.png \
&& wget http://tiles.kerbalmaps.com/mun/sat/2/6/3.png -O 0006.png \
&& wget http://tiles.kerbalmaps.com/mun/sat/2/7/3.png -O 0007.png \
&& wget http://tiles.kerbalmaps.com/mun/sat/2/0/2.png -O 0100.png \
@tsnoad
tsnoad / openscad_iso_thread
Created February 28, 2016 06:01
Simple openscad function/module to create ISO screw threads
module m5_thread(height=1,quality=4) {
r_maj = 5/2;
pitch = 0.8;
iso_h = sqrt(3)/2*pitch;
r_min = r_maj - 5/8 * iso_h;
linear_extrude(height=height,twist=360*height/pitch) hull() for(j=[0,1]) mirror([j,0,0]) for(i=[0:(180/8)/quality:180]) {
if (i==0) {
square([0.01,r_maj]);
} else if (i==180) {
@tsnoad
tsnoad / ft_checkdig.php
Last active August 29, 2015 14:03
foxtrot customer id check digit algorithm
# php -r '<?php $i = 500295; $reg = 0; $xi = strrev($i); for($j=0;$j<strlen($xi);$j++) { $reg += substr($xi, $j, 1)*pow(2,$j+1); } var_dump($i."\t".($reg)."\t".fmod(fmod((11-fmod($reg,11)),11),10));'
<?php
for ($i=1;$i<100;$i++) {
$reg = 0;
$xi = strrev($i);
for($j=0;$j<strlen($xi);$j++) {
@tsnoad
tsnoad / gist:6518408
Created September 11, 2013 01:47 — forked from e0da/gist:1989787
#!/usr/bin/env ruby
require 'base64'
require 'digest'
# get 16 random hex bytes
#
def new_salt
16.times.inject('') {|t| t << rand(16).to_s(16)}
end
<?php
if ($_FILES['userfile']['size'] > 5 * 1024 * 1024) {
$error = 'File is too large.';
@unlink($_FILES['userfile']['tmp_name']) || $error .= $php_errormsg;
}
@tsnoad
tsnoad / year_to_finyear.sql
Last active December 14, 2015 00:48
get financial year from a date in oracle
with dates as (
select sysdate-240 as sometime from dual
union select sysdate-180 as sometime from dual
union select sysdate-120 as sometime from dual
union select sysdate-60 as sometime from dual
union select sysdate as sometime from dual
union select sysdate+60 as sometime from dual
union select sysdate+120 as sometime from dual
union select sysdate+180 as sometime from dual
union select sysdate+240 as sometime from dual
@tsnoad
tsnoad / gist:2642139
Created May 9, 2012 05:33
simple checking and correction of australian and international phone numbers
<?
function checkPhone($int_dial_code, $area_code, $local_number) {
//try to check and reformat australian numbers
if ($int_dial_code == "61") {
//combine the area code and local number
$full_phone = $area_code.$local_number;
//strip spaces and hyphens
$full_phone = str_replace(array(" ", "-"), "", $full_phone);