Skip to content

Instantly share code, notes, and snippets.

@capex
capex / gist_of_python.md
Last active March 19, 2017 06:19
The gist of Python 3.x (interesting bits). Source: Learn to Program: The Fundamentals by University of Toronto @ Coursera.

Operators

  • ** : exponentiation
  • // : integer division (you only get the integer from the division)
  • % : modulo, gives you the numerator of the fractional part of a division.

Order of Operations

  • **
  • - (negation)
  • * / // %
  • + -
function throttle( fn, time ) {
var t = 0;
return function() {
var args = arguments, ctx = this;
clearTimeout(t);
t = setTimeout( function() {
fn.apply( ctx, args );
}, time );
};
@capex
capex / 0_reuse_code.js
Created June 26, 2014 12:44
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@capex
capex / bigOrSmall.c
Created October 10, 2012 07:24
Discover if you should use big numbers first, or small numbers in C
/*
Shows if big or small numbers should be used first.
*/
#include <stdio.h>
int main(int argc, char const *argv[])
{
@capex
capex / gcd.c
Created October 10, 2012 07:06
GCD in C
/*
Computes greatest common divisor of two numbers.
*/
#include <stdio.h>
// function prototype
int gcd (int a, int b);
@capex
capex / gist:3173865
Created July 25, 2012 01:36
Leap year finder in C
// Gets user input for year and month, and then tells you the number of days in that month.
// Takes care of the leap year problem as well.
#include <stdio.h>
int main(int argc, const char * argv[])
{
int year, month, days;
@capex
capex / seconds-in-a-year.c
Created July 24, 2012 12:54
Seconds in a year
#include <stdio.h>
#include <math.h>
int main(void)
{
//number of seconds in a year.
int seconds_in_year;
seconds_in_year = 60*60*24*365;
@capex
capex / howtogit.html
Created December 12, 2011 01:46
How to Git
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
</head>
<body>
<h1> Git is so great! </h1>
</body>
@capex
capex / gist:1360198
Created November 12, 2011 07:28
A for loop
for (var number = 0; number <= 12; number = number + 2)
print(number);
@capex
capex / gist:1360193
Created November 12, 2011 07:25
A Do loop
do {
var input = prompt("Who are you?");
} while (!input);