Skip to content

Instantly share code, notes, and snippets.

@rmccullagh
rmccullagh / Selection Sort
Created October 4, 2013 18:08
selection sort
#include <iostream>
#include <iomanip>
using namespace std;
int main()
{
int ar[] = {64, 25, 12, 22, 11};
int a = 0;
@rmccullagh
rmccullagh / selector.js
Created April 9, 2014 01:45
JavaScript DOM framework (not tested)
(function(window) {
'use strict';
var
CLASS_REG = /^\.[a-zA-Z_]+[a-zA-Z_0-9-]*/
,ID_REG = /^\#[a-zA-Z_]+[a-zA-Z_0-9-]*/;
var Selector = function(s) {
return new Selector.fn.init(s);
}
DROP DATABASE IF EXISTS GROUP_PROJECT_2014;
CREATE DATABASE GROUP_PROJECT_2014;
USE GROUP_PROJECT_2014;
CREATE TABLE Team (
team_num DECIMAL(2,0) PRIMARY KEY,
name CHAR(20)
);
CREATE TABLE Coach(
team_num DECIMAL(2,0) NOT NULL,
last_name CHAR(20),
@rmccullagh
rmccullagh / gist:9f3cfc585f0fd92a2583
Created July 28, 2014 00:15
three different ways of writing the same thing
function fn() {
var args = Array.prototype.slice.call(arguments);
var node;
var i = 0;
while(node = args.shift()) {
if(typeof node == 'function') {
node();
console.log("Function found at index %d", i);
break;
@rmccullagh
rmccullagh / camel_case_rev.js
Created October 22, 2014 19:51
Reverse Camel Case implementation
{
if(! word)
return;
word = (word).toString();
var ret = "";
for(var i = 0; i < word.length; i++)
{
@rmccullagh
rmccullagh / camel_case_rev.js
Created October 22, 2014 19:51
Reverse Camel Case implementation
function camel_case_rev(word)
{
if(! word)
return;
word = (word).toString();
var ret = "";
for(var i = 0; i < word.length; i++)
#include <stdio.h> // fprintf
#include <stdlib.h> // malloc
#include <string.h> // strlen
#include <ctype.h> // toupper, tolower
/*
* a string is an array of characters, in C, all arrays
* are always passed never passed value, always a pointer to
* the variable
* This is why the caller does not need to call the function like:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
/*
* const char* const read only
* const char* is read/write
*/
int find_str_in_str(const char* const base, const char* const sub)
#include <iostream>
#include <map>
#include <string>
#include <algorithm>
#define NL std::cout << std::endl
using namespace std;
void __(const char *s) {
#include <iostream>
#include <deque>
#include <algorithm>
#include <iterator>
#include <cstring>
#include <vector>
using namespace std;
// non-breaking-s-pace