Skip to content

Instantly share code, notes, and snippets.

'use strict';
var head = null; // head of linked list
function addNode(val) {
var node = {
val: val,
next: null
}
'use strict';
var hashSize = 3; // small so we get collisions
var hashArray = new Array(hashSize);
var bigPrime = 1223;
function calculateHash(key) {
var hash = 0;
if(key.length > 0){
for (var i = 0; i < key.length; i++) {
@ChrisLTD
ChrisLTD / InfiniteScroll-ES6.js
Last active January 6, 2020 18:00
Infinite "Scroll" javascript module for ES6
'use strict';
// Infinite scrolling loader, fires off a button click
//
// Sample HTML:
// <div class="js-infinite-scroll">
// POSTS HERE
// <a href="/url-to-more-content" class="js-infinite-scroll-next-button">Load More</a>
// </div>
// <div class="js-infinite-scroll-loading">...</div>

Getting Started

Install Node.js https://nodejs.org

Using terminal in this folder, run:

npm install -g bower
bower install
npm install
@ChrisLTD
ChrisLTD / custom-column-wp-admin.php
Created October 19, 2015 21:40
Custom Column Sorting Example Wordpress Admin
<?php
// *
// Show Alternate ID column in admin
// *
add_filter('manage_posts_columns', 'add_alternate_id_columns', 10, 2);
function add_alternate_id_columns($posts_columns, $post_type)
{
if( $post_type == 'offer-download' ) {
$posts_columns['offer_download_id'] = 'Internal ID';
@ChrisLTD
ChrisLTD / application_controller.rb
Created June 26, 2015 16:46
Apex domain redirect in Rails 4
class ApplicationController < ActionController::Base
# Prevent CSRF attacks by raising an exception.
# For APIs, you may want to use :null_session instead.
protect_from_forgery with: :exception
before_filter :check_domain_and_ssl
def check_domain_and_ssl
if Rails.env.production? and (request.protocol.downcase + request.host.downcase) != 'https://www.mywebsite.com'
redirect_to 'https://www.mywebsite.com' + request.fullpath
#!/bin/bash
#echo on
set -x
echo load postgres
sudo defaults write /Library/LaunchDaemons/org.macports.postgresql94-server.plist Disabled -bool false
sudo launchctl load /Library/LaunchDaemons/org.macports.postgresql94-server.plist
echo start redis
class func setupNotificationFor(hourTask:HourTask) {
// clear all old notification first if there is one
for notification in UIApplication.sharedApplication().scheduledLocalNotifications as! [UILocalNotification] {
if (notification.userInfo!["UUID"] as! String == hourTask.theID) {
UIApplication.sharedApplication().cancelLocalNotification(notification)
println("old notification removed")
break
}
}
@ChrisLTD
ChrisLTD / index.html
Last active August 29, 2015 14:16
Simple down for maintenance page
<html>
<head>
<title>Down for maintenance</title>
<style>
body { background: #444; color: #eee; padding: 3em 2em; text-align: center; font-family: 'Helvetica Neue', Arial, Helvetica, sans-serif; -webkit-font-smoothing: antialiased; }
</style>
</head>
<body>
import UIKit
class myClass {
var myVal = 1
}
func addVals(myClasses: [myClass]) -> Int {
var result = 0
for thisClass in myClasses {
result += thisClass.myVal