Skip to content

Instantly share code, notes, and snippets.

View melvinmt's full-sized avatar

Melvin Tercan melvinmt

View GitHub Profile
def is_prime(x):
if x < 2:
return False
if x == 2:
return True
if x % 2 == 0:
return False
i = 3
while i < x:
if x % i == 0:
@melvinmt
melvinmt / learngo.go
Created September 4, 2013 17:26
Code from http://learnxinyminutes.com/docs/go/ formatted with gofmt
// Single line comment
/* Multi-
line comment */
// A package clause starts every source file.
// Main is a special name declaring an executable rather than a library.
package main
// Import declaration declares library packages referenced in this file.
/* The Grid ---------------------- */
.lt-ie9 .row { width: 940px; max-width: 100%; min-width: 768px; margin: 0 auto; }
.lt-ie9 .row .row { width: auto; max-width: none; min-width: 0; margin: 0 -15px; }
.lt-ie9 .row.large-collapse .column,
.lt-ie9 .row.large-collapse .columns { padding: 0; }
.lt-ie9 .row .row { width: auto; max-width: none; min-width: 0; margin: 0 -15px; }
.lt-ie9 .row .row.large-collapse { margin: 0; }
.lt-ie9 .column, .columns { float: left; min-height: 1px; padding: 0 15px; position: relative; }
.lt-ie9 .column.large-centered, .columns.large-centered { float: none; margin: 0 auto; }
@melvinmt
melvinmt / gist:3140173
Created July 19, 2012 01:30 — forked from idan/gist:3135754
Re: A Sample Post

This is me quoting this.

Hello there! This is a sample post for gist.io, a super-lightweight writing soapbox for hackers.

Now look up. Further. Above the post title. See that grey text with the gist ID?

Now back to me. That grey text is a link! Open that sucker in a new tab to see the source for this post. Also, I'm on a horse.

This is a major heading

@melvinmt
melvinmt / HttpClient.php
Created November 4, 2011 18:55
Tinypay POST method fix
<?php
/*
* Mashape PHP Client library.
*
* Copyright (C) 2011 Mashape, Inc.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
<?php
require_once('phpFlickr.php');
$f = new phpFlickr($flickr_api_key, $flickr_api_secret);
$request = $f->photos_getSizes($photo['id']);
// assume that largest size comes last:
$large = $request[count($request)-1];
<?php
require_once('phpFlickr.php');
$f = new phpFlickr($flickr_api_key, $flickr_api_secret);
$request = $f->people_getPhotos($user_id);
foreach ($request['photos']['photo'] as $photo){
<?php
require_once('phpFlickr.php');
$f = new phpFlickr($flickr_api_key, $flickr_api_secret);
$f->auth("read");
?>
<?php
require_once('Tinypayme.php');
$t = new Tinypayme($mashape_api_key);
$request = $t->createItem(
$access_token = $access_token,
$title =stripslashes($data['title']),
$currency = $data['currency'],
<?php
// construct upload url
$upload_url = 'https://tinypay.me/mashape';
$ch = curl_init();
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_VERBOSE, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);