Skip to content

Instantly share code, notes, and snippets.

View ngm's full-sized avatar
🙂

Neil M ngm

🙂
View GitHub Profile
@ngm
ngm / gist:69b593a5831a5b4d694e5907b8e31cc9
Created June 6, 2019 13:46 — forked from bryhal/gist:4129042
MYSQL: Generate Calendar Table
DROP TABLE IF EXISTS time_dimension;
CREATE TABLE time_dimension (
id INTEGER PRIMARY KEY, -- year*10000+month*100+day
db_date DATE NOT NULL,
year INTEGER NOT NULL,
month INTEGER NOT NULL, -- 1 to 12
day INTEGER NOT NULL, -- 1 to 31
quarter INTEGER NOT NULL, -- 1 to 4
week INTEGER NOT NULL, -- 1 to 52/53
day_name VARCHAR(9) NOT NULL, -- 'Monday', 'Tuesday'...
@ngm
ngm / functions.php
Created March 28, 2019 22:50
Wordpress embed handler for invidio.us
wp_embed_register_handler( 'invidious_watch', '#https?://invidio\.us/watch\?v=([A-Za-z0-9\-_]+)#i', 'wp_embed_handler_invidious' );
wp_embed_register_handler( 'invidious_embed', '#https?://invidio\.us/embed/([A-Za-z0-9\-_]+)#i', 'wp_embed_handler_invidious' );
function wp_embed_handler_invidious( $matches, $attr, $url, $rawattr ) {
$embed = sprintf(
'<iframe src="https://invidio.us/embed/%1$s" frameborder="0" scrolling="no" marginwidth="0" marginheight="0" width="600" height="400"></iframe>',
esc_attr($matches[1])
);
return $embed;
}
function add_mastodon_syndication_target($synd_urls, $user_id)
{
$masto_target['uid'] = "social_coop";
$masto_target['name'] = "social.coop";
$synd_urls[] = $masto_target;
return $synd_urls;
}
add_filter("micropub_syndicate-to", "add_mastodon_syndication_target", 10, 2);
@ngm
ngm / messy.html
Created July 21, 2017 09:00
HTML to be cleaned
<p style="margin-bottom: 0px; font-size: 18px; line-height: normal; font-family: Helvetica; color: rgb(6, 2, 1); -webkit-text-stroke-width: initial; -webkit-text-stroke-color: rgb(6, 2, 1);"><span style="font-kerning: none"><b>Aylesbury Restart Party &amp; Makers' Fair</b></span></p>
<p style="margin-bottom: 0px; line-height: normal; font-family: 'Lucida Grande'; color: rgb(6, 2, 1); -webkit-text-stroke-width: initial; -webkit-text-stroke-color: rgb(6, 2, 1);"><span style="font-kerning: none"><b>Jul 22, 2017</b></span></p>
<p style="margin-bottom: 0px; line-height: normal; font-family: 'Lucida Grande'; color: rgb(6, 2, 1); -webkit-text-stroke-width: initial; -webkit-text-stroke-color: rgb(6, 2, 1); background-color: rgb(157, 215, 226); min-height: 17px;"><span style="font-kerning: none"><b></b></span><br></p>
<p style="margin-bottom: 0px; line-height: normal; font-family: 'Lucida Grande'; color: rgb(6, 2, 1); -webkit-text-stroke-width: initial; -webkit-text-stroke-color: rgb(6, 2, 1);"><span style="font-kerni
@ngm
ngm / packages.el
Last active November 13, 2019 21:44
Basic spacemacs org-brain layer
;; put this file in ~/.emacs.d/private/org-brain
;; then add org-brain into your dotspacemacs-configuration-layers in .spacemacs
(defconst org-brain-packages
'(org-brain)
)
;; see https://github.com/Kungsgeten/org-brain#setup-and-requirements
(defun org-brain/init-org-brain ()
(use-package org-brain
@ngm
ngm / devbox.boxstarter
Last active April 1, 2016 14:42
Boxstarter Script
# antivirus
cinst autohotkey # avg installer uses autohotkey...
cinst avgantivirusfree
# windows updates + reboot
Install-WindowsUpdate -acceptEula
if (Test-PendingReboot) { Invoke-Reboot }
# iis
cinst IIS-WebServerRole -source windowsfeatures
@ngm
ngm / fibonacci_loopy.io
Created December 3, 2011 16:05
Seven Languages in Seven Weeks - Io - Day 2 - Fibonacci
fibonacci_loopy := method(n,
fib_list := List clone
for(i, 0, n-1,
if (i == 0 or i == 1,
fib_list append(1),
fib_list append(fib_list at(i-2) + fib_list at(i-1))
)
)
fib_list at(fib_list size-1)
@ngm
ngm / acts_as_csv_module.rb
Created November 29, 2011 23:09
Seven Languages in Seven Weeks - Ruby - Day 3 - CsvRow
module ActsAsCsv
include Enumerable
def self.included(base)
base.extend ClassMethods
end
module ClassMethods
def acts_as_csv
@ngm
ngm / guess_the_number.rb
Created November 27, 2011 15:06
Seven Languages in Seven Weeks - Ruby - Day 1 - Guess the number
puts "\nHello. What's your name?"
print "[Your name]: "
name = gets.chomp
puts
puts "Hello #{name}."
theMagicNumber = rand(100)+1
@ngm
ngm / grep.rb
Created November 27, 2011 15:01
Seven Languages in Seven Weeks - Ruby - Day 2 - Grep
puts
print "File name: "
filename = gets.chomp
puts
print "Search term: "
phrase = gets.chomp
File.open(filename, "r") do |file|