Skip to content

Instantly share code, notes, and snippets.

@kirkouimet
kirkouimet / OrderIdentifierGenerator.js
Last active May 5, 2023 16:30
Generate an easy to communicate order identifier with a check digit with a keyspace in the trillions
class OrderIdentifierGenerator {
static characters = '234567CDFGHJKLMNPQRTVWXYZ';
// Generate a new identifier
static generate() {
const partialIdentifier = OrderIdentifierGenerator.generatePartialIdentifier();
let identifier = (
partialIdentifier.slice(0, 3) +
@kirkouimet
kirkouimet / php-analytics.php
Created November 14, 2011 04:17
PHP analytics function
function getAnalytics() {
$user = $_SERVER['HTTP_USER_AGENT'];
$browser = 'Unknown';
$platform = 'Unknown';
$version= '';
// First get the platform?
if(preg_match('/linux/i', $user)) {
$platform = 'Linux';
}
var view = new View();
view.width = 1024;
view.height = 768;
view.render();
Verifying my Blockstack ID is secured with the address 1KfdWMJuVKdLB2eCLXNxnkmU1TmdzC9rfM https://explorer.blockstack.org/address/1KfdWMJuVKdLB2eCLXNxnkmU1TmdzC9rfM
@kirkouimet
kirkouimet / 779244.html
Last active October 30, 2017 16:11
We need a way to wrap console.log and preserve the file and line number
<html>
<head>
<title>We need a way to wrap console.log and preserve the file and line number</title>
<script>
function customLog() {
var processedArguments = arguments;
// Do something with the arguments besides logging them, maybe format them or store them
// ...
// Send the output to Developer Tools
@kirkouimet
kirkouimet / gist:5208767
Created March 20, 2013 21:43
Scrape titles from Reddit with node.js and node.io
require('node.io').scrape(function() {
this.getHtml('http://www.reddit.com/', function(err, $) {
var stories = [];
$('.entry .title').each(function(title) {
stories.push(title.text);
});
this.emit(stories);
});
});
implement = function(classToReceiveImplementation, classToImplement) {
for(var classToImplementProperty in classToImplement) {
if(classToReceiveImplementation[classToImplementProperty] === undefined) {
//console.log(classToImplementProperty, 'does not exist on class, copying');
classToReceiveImplementation[classToImplementProperty] = cloneProperty(classToImplement[classToImplementProperty]);
}
}
for(var classToImplementPrototypeProperty in classToImplement.prototype) {
if(classToReceiveImplementation.prototype[classToImplementPrototypeProperty] === undefined) {
<html>
<head>
<title>Overscrolling HTML Elements in Chromium on OS X using a Trackpad</title>
<style>
html {
font-family: sans-serif;
border: 4px solid #00AAFF;
}
</style>
</head>
@kirkouimet
kirkouimet / CopyAsanaTasks.php
Last active December 18, 2015 14:58 — forked from mhdhejazi/CopyAsanaTasks.php
Allows you to duplicate a project in Asana and put it in another workspace
<?php
function asanaRequest($methodPath, $httpMethod = 'GET', $body = null) {
$apiKey = 'ASANA_API_KEY_HERE'; /// Get it from http://app.asana.com/-/account_api
$url = "https://app.asana.com/api/1.0/$methodPath";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC ) ;
curl_setopt($ch, CURLOPT_USERPWD, $apiKey);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
@kirkouimet
kirkouimet / gist:5596828
Created May 17, 2013 03:52
Add baconify method to the string class
String.prototype.baconify = function() {
return this.replace(/({|})/gi, 'BACON');
}
'{"jsonKey":"jsonValue"}'.baconify();
//"BACON"jsonKey":"jsonValue"BACON"