Skip to content

Instantly share code, notes, and snippets.

View wlkns's full-sized avatar

JW wlkns

View GitHub Profile
@wlkns
wlkns / mixins.jade
Last active August 29, 2015 14:07 — forked from shaneriley/mixins.jade
// Writing JS for everything is great and all, but I don't want to see JS
// inline in my Jade templates. Thankfully, there are ways of abstrating it
// into mixins!
// Want some Rails-like helpers?
mixin link_to(name, href)
- href = href || "#"
a(href="#{href}")= name
// How about a single editing point for a class name?
@wlkns
wlkns / app.js
Last active January 1, 2016 09:09
Socket.IO Authentication Tutorial (Server and Client) - http://wlkns.co/?p=52
/* app.js
*
* This code is the client to connect to the Socket.IO server run in the clients browser */
jQuery(document).ready(function(){
/* Connect the socket */
socket = io.connect('http://localhost:8080', {
/* Pass the authentication token as a URL parameter */
query: $.param({token: 'i271az2Z0PMjhd6w0rX019g0iS7c2q4R'})
/* My application is more complicated, so I use jQuery's .param utility to convert the Object to an URL string e.g. 'token=abc&etc=cde' */
@wlkns
wlkns / MY_Form_validation.php
Created October 15, 2013 18:32
CodeIgniter Postcode Validation Form Validation (and global call back functionality), read more at http://wlkns.co/codeigniter/global-form-validation-callback-functionality-and-postcode-checker-in-codeigniter/
<?php defined('BASEPATH') or die('Direct access to this file is not permitted.')
class MY_Form_validation extends CI_Form_validation
{
/**
* Postcode Validation Callback
*/
public function valid_postcode( $string )
{
@wlkns
wlkns / CardTest.java
Last active December 25, 2015 10:19
Java Read Cards/Fobs using ACR122U NFC Reader
import java.io.*;
import java.util.*;
import javax.smartcardio.*;
public class CardTest {
final protected static char[] hexArray = "0123456789ABCDEF".toCharArray();
public static String bytesToHex(byte[] bytes) {
char[] hexChars = new char[bytes.length * 2];