Skip to content

Instantly share code, notes, and snippets.

@Haolicopter
Haolicopter / pull_request_template.md
Last active September 12, 2018 14:52
Pull request template

Description

Motivation and Context

How Has This Been Tested?

@Haolicopter
Haolicopter / n_diagonals.py
Created June 8, 2018 19:31
Solve n diagonals problem with backtracking
def can_be_extended_to_solution(perm, n, m):
# Too many non diagonal squares
if perm.count(2) > m*m - n:
return False
new = len(perm) - 1
# New square has no diagonal
if perm[new] == 2:
return True
@Haolicopter
Haolicopter / snowplow_test_tracker.html
Last active May 28, 2018 19:44
Snowplow test tracker
<!DOCTYPE html>
<html>
<head>
<title>Snowplow test tracker</title>
<script>
; (function (p, l, o, w, i, n, g) {
if (!p[i]) {
p.GlobalSnowplowNamespace = p.GlobalSnowplowNamespace || [];
p.GlobalSnowplowNamespace.push(i); p[i] = function () {
{
"type": "object",
"title": "dev_table",
"description": "A very simple custom context",
"properties": {
"affiliate_id": {
"type": "string"
},
"c1": {
"type": "string"
@Haolicopter
Haolicopter / MillerRabinAlgorithm.cpp
Created November 27, 2017 18:34
Prime number test
//
// Miller-Rabin Algorithm
//
// Created by Hao Ling on 2014-03-19.
// Copyright (c) 2014 Hao Ling. All rights reserved.
//
#include <iostream>
#include "math.h"
this.handleApiRequest = function(request, sender, sendResponse) {
console.log(request)
if (!request || !request.endpoint)
return;
var response;
$.ajax({
method: request.method,
url: 'https://admin.jumbleberry.com/jbx-api/' + request.method.toLowerCase() + request.endpoint
}).done(function(res) {
@Haolicopter
Haolicopter / randomDomains.php
Last active September 7, 2017 18:54
Generate random domains
<?php
$dict = file('basicWords');
$file = 'domains.txt';
$numOfDomains = 300;
$content = '';
for ($i=0; $i < $numOfDomains; $i++) {
$content .= generateRandomDomain($dict) . "\n";
}
file_put_contents($file, $content);
@Haolicopter
Haolicopter / chromeDinosaurCheater.js
Created June 16, 2017 04:32
Chrome Dinosaur Game Cheater
// Keep a copy of original runner
var originalRunner=Runner.prototype.gameOver
// Overwrite gameover function so we don't die
Runner.prototype.gameOver=function(){console.log("Its over when I say its over")}
// Super speed run
Runner.instance_.setSpeed(15000)
// Change back to original game when you are sick of cheating
Runner.prototype.gameOver=originalRunner
@Haolicopter
Haolicopter / maxDuffleBagValue.py
Created June 16, 2017 04:22
It takes a list of cake type tuples and a weight capacity, it returns the maximum monetary value the duffel bag can hold.
#!/usr/bin/env python3
# The function maxDuffleBagValue() takes a list of cake type tuples
# and a weight capacity, it returns the maximum monetary value
# the duffel bag can hold.
#
# items are formated are formated as (weight, value)
# cap is the weight capacity
# isUnique indicates if there are multiple of the same item
@Haolicopter
Haolicopter / controlComputerThroughEmail.py
Created June 15, 2017 21:37
Send magent link through email to remote machine to start auto download
#!/usr/bin/env python3
# One chanllenge remains:
# 1. how to check if the download is completed and send a notification.
# Chanllenges solved:
# how to extract the magent link inside gamil from werid additional links.
# Write a program that checks an email acount every 15 minutes for
# any instructions you email it and executes those instructions automatically.