Skip to content

Instantly share code, notes, and snippets.

@pjt33
pjt33 / GolfScriptGolfer.java
Last active Aug 29, 2015
GolfScript golfer
View GolfScriptGolfer.java
import java.io.*;
import java.util.*;
public class GolfScriptGolfer {
public static void main(String[] args) throws Exception {
if (args.length == 1) {
String src = readFully(args[0]);
String golfed = golf(src);
String outputFile = (args[0].endsWith(".gs") ? args[0].substring(0, args[0].length() - 3) : args[0]) + ".min.gs";
@pjt33
pjt33 / PracticalNumbers.java
Last active Dec 22, 2015
Enumerator for practical numbers
View PracticalNumbers.java
package com.akshor.pjt33.math;
import java.util.*;
public class PracticalNumbers
{
public static void main(String[] args) {
Generator gen = new Generator();
// Print all practical numbers up to 30000
for (int pr = gen.next(); pr <= 30000; pr = gen.next()) {
@pjt33
pjt33 / Build subtitles
Last active Dec 19, 2015
Coursera video list: things to run in the console 1. Generate wiki markup for the subtitles page. 2. Generate a bash script to download the resources
View Build subtitles
$('a.lecture-link').each(function(){
var $lectureLink = $(this);
var lectureId = $lectureLink.data('lecture-id');
var title = $lectureLink.text().trim().replace(/ *\([0-9]+:[0-9]+\)/, '');
console.log('* ' + title + ' [[Scigast:Subtitles:Lecture' + lectureId + ':en|English]] | [[Scigast:Subtitles:Lecture' + lectureId + ':es|Español]]');
}),null;
@pjt33
pjt33 / gist:5898943
Last active Dec 19, 2015
PHP stacktrace in a loggable/echoable form.
View gist:5898943
$st = debug_backtrace();
$lineNo = '';
$stackTrace = '';
foreach ($st as $line)
{
if (isset($line['class'])) $stackTrace .= $line['class'].$line['type'].$line['function'].' at line '.$lineNo . "\n";
else $stackTrace .= $line['function'].' in '.$line['file'].' line '.$lineNo . "\n";
$lineNo = $line['line'];
}
You can’t perform that action at this time.