Skip to content

Instantly share code, notes, and snippets.

article, aside, dialog, figure, footer, header, hgroup, menu, nav, section {display: block}
/* Use this to cause a function to fire no more than once every 'ms' milliseconds.
For example, an expensive mousemove handler:
$('body').mouseover(ratelimit(function(ev) {
// ...
}, 250));
*/
function ratelimit(fn, ms) {
var last = (new Date()).getTime();
#include <stdio.h>
int main()
{
unsigned int a = 1, b = 1, c = 2, sum = 0;
while (c < 4000000)
{
c = a + b;
sum += c * !(c % 2);
/*
Great little debuging snippet found while browsing.
The code adds different coloured borders to the assets
depending on its level.
Leave commented out if not needed.
*/
* { outline: 2px dotted red }
* * { outline: 2px dotted green }
#include <stdio.h>
int main( )
{
char string[]={"this is a string"};
char searchchar = 'i';
char replacechar = 'X';
char *ptr; // current position in string
/**
* Solution by KushalP
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
void condense_by_removing(char *z_terminated, char char_to_remove);
/* Pad an Integer with zeros depending on a
* given length provided
*/
var zeroPad = function(n, totalDigits) {
n = n.toString();
var pd = '';
if (totalDigits > n.length)
for (i=0; i < (totalDigits-n.length); i++)
pd += '0';
#include <stdlib.h>
#include <stdio.h>
struct list_element
{
int val;
struct list_element *next;
};
typedef struct list_element item;
set ai " auto indenting
set history=100 " keep 100 lines of history
set ruler " show the cursor position
syntax on " syntax highlighting
set hlsearch " highlight the last searched term
filetype plugin on " use the file type plugins
" clean up our tab usage
set softtabstop=4
set tabstop=4
class LinkedList(object):
"""
Attempting to learn the basics of ADTs again.
Note to self: don't ever use this, stick with list() methods
"""
class Node(object):
def __init__(self, item):
self.value = item
self.next = None