Skip to content

Instantly share code, notes, and snippets.

View xunker's full-sized avatar

Matthew Nielsen xunker

View GitHub Profile
@mojaray2k
mojaray2k / Trickshots 1
Last active May 16, 2022 16:45
Use jQuery to send a HEAD request with AJAX and get the size of a file without downloading it. This snippet places the size of the file in braces next to its name. The script issues a HEAD request, which only returns the headers and not the actual content of the file, which means that these requests are fast and lightweight.
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Display files sizes next to download links</title>
</head>
<body>
<a href="001.html" class="fetchSize">First Trickshot</a>
<a href="034.html" class="fetchSize">This Trickshot</a>
<a href="ball.png" class="fetchSize">Ball.png</a>
@scaryguy
scaryguy / change_primary_key.md
Last active October 6, 2025 15:35
How to change PRIMARY KEY of an existing PostgreSQL table?
-- Firstly, remove PRIMARY KEY attribute of former PRIMARY KEY
ALTER TABLE <table_name> DROP CONSTRAINT <table_name>_pkey;
-- Then change column name of  your PRIMARY KEY and PRIMARY KEY candidates properly.
ALTER TABLE <table_name> RENAME COLUMN <primary_key_candidate> TO id;
@jordanbyron
jordanbyron / authentication.rb
Last active January 2, 2019 21:06
Custom authentication strategy for Devise with login screens, routes, and no database_authenticatable - Full writeup: http://blog.jordanbyron.com/post/54013166913/devise-authentication-strategy-without
module AuthApp
class CustomAuthentication < Devise::Strategies::Authenticatable
# This check is run before +authenticate!+ is called to determine if this
# authentication strategy is applicable. In this case we only try to authenticate
# if the login and password are present
#
def valid?
login && password
end
@bsstokes
bsstokes / filter-password.nginx.conf
Created June 10, 2013 13:43
Filter the password from a request in the nginx access log.
log_format filtered_log '$remote_addr - $http_host - $remote_user [$time_local] {$request_time} {$upstream_response_time} $upstream_addr'
'"$filtered_request" $status $body_bytes_sent '
'"$http_referer" "$http_user_agent"';
server {
root /home/ubuntu/password_test/www;
index index.html index.htm;
server_name password_test;
location / {
@paul-english
paul-english / hack.coffee
Created June 5, 2013 21:16
Hubot hacker plugin
# Description:
# None
#
# Dependencies:
# None
#
# Configuration:
# None
#
# Commands:
@rsbohn
rsbohn / borg.ps1
Last active December 17, 2015 23:09 — forked from xunker/borg.rb
#not quite the same but still...
#(voices are limited on Windows 7)
#voices = %w[Agnes Alex Bruce Bubbles Fred Junior Kathy Princess Ralph Vicki Victoria]
$phrases = @(
"We are the Borg.",
"Lower your shields and surrender your ships.",
"We will add your biological and technological distinctiveness to our own.",
"Your culture will adapt to service us.",
"Resistance is futile."
@probonopd
probonopd / Send infrared commands from the Arduino to the iRobot Roomba
Created March 17, 2013 10:42
Send infrared commands from the Arduino to the iRobot Roomba. Use a transistor to drive the IR LED from pin D3 for maximal range.
#include <IRremote.h>
/*
Send infrared commands from the Arduino to the iRobot Roomba
by probono
2013-03-17 Initial release
@TooTallNate
TooTallNate / endianness.js
Created February 10, 2013 20:32
Get host machine endianness using JavaScript Typed Arrays (polyfill for `os.endianness()` in node.js)
function endianness () {
var b = new ArrayBuffer(4);
var a = new Uint32Array(b);
var c = new Uint8Array(b);
a[0] = 0xdeadbeef;
if (c[0] == 0xef) return 'LE';
if (c[0] == 0xde) return 'BE';
throw new Error('unknown endianness');
}
@myronmarston
myronmarston / explanation.md
Last active October 22, 2020 18:16
Explanation for why `its` will be removed from rspec-3

its isn't core to RSpec. One the of the focuses of RSpec is on the documentation aspects of tests. Unfortunately, its often leads to documentation output that is essentially lies. Consider this spec:

User = Struct.new(:name, :email)

describe User do
  subject { User.new("bob") }
  its(:name) { should == "bob" }
end
@joekiller
joekiller / gtk-firefox.sh
Last active October 1, 2024 21:25 — forked from phstc/gtk-firefox.sh
INSTALL FIREFOX ON AMAZON LINUX X86_64 COMPILING GTK+
#!/bin/bash
# GTK+ and Firefox for Amazon Linux
# Written by Joseph Lawson 2012-06-03
# http://joekiller.com
# http://joekiller.com/2012/06/03/install-firefox-on-amazon-linux-x86_64-compiling-gtk/
# chmod 755 ./gtk-firefox.sh
# sudo ./gtk-firefox.sh