This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Callme { | |
void call(String message) { | |
try { | |
Thread.sleep(1000); | |
} catch(InterruptedException e) { | |
System.out.println("Interrupted. Message is " + message); | |
} | |
System.out.print("[" + message); | |
System.out.println("]"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function(P) { | |
var timer = setInterval(function() { | |
var requestCount = P.getEntriesByType("resources").filter(res => res.initiatorType === "script" && res.responseEnd === 0).length; | |
if (requestCount === 0) { | |
// all requests are loaded | |
// begin next step here... | |
clearInterval(timer); | |
} | |
}, 16 * 4); // interval set to approx. 100ms |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Uses python3 | |
import sys | |
import math | |
class Node: | |
def __init__(self, coords): | |
self.left = None | |
self.right = None | |
self.coords = coords |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void merge_sort(vector<int> &a, int left, int right) { | |
// base case | |
if (left + 1 >= right) { | |
return; | |
} | |
// recursion case | |
int mid = (left + right) / 2; | |
merge_sort(a, left, mid); | |
merge_sort(a, mid, right); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var LEFT = 0; | |
var RIGHT = 1; | |
function getZeros(length) { | |
return (new Array(length)).join('a').split('a').map(function() { return 0; }); | |
} | |
function padTo(array, length, direction) { | |
var result = array.slice(0); | |
var args = getZeros(length); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var WebpackDevServer = require('webpack-dev-server'); | |
var webpack = require('webpack'); | |
var devConfig = require('../webpack.config.dev'); | |
var compiler = webpack(devConfig); | |
var IPAddress = require('./get-ip')(); | |
new WebpackDevServer(compiler, { | |
contentBase: './src', | |
publicPath: '/assets/', |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head></head> | |
<body> | |
<button id="btn" style="transform: scale(3); margin: 100px;">touch to play</button> | |
</body> | |
<script> | |
$el = document.querySelector('#btn'); | |
var myContext = new (window.AudioContext || window.webkitAudioContext)(); | |
var path = 'ended.mp3'; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
AudioComponent.prototype.initFromBuffer = function(bufferData) { | |
this.panner = this.context.createPanner(); | |
this.gainNode = this.context.createGain(); | |
this.sourceNode = this.context.createBufferSource(); | |
this.context.decodeAudioData(bufferData, function(buffer) { | |
this.meta.duration = 1000 * buffer.duration; //in milliseconds | |
// connect them up | |
this.sourceNode = buffer; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$link.setAttribute('download', fileName); | |
$link.setAttribute('title', 'download generated logo'); | |
if(format == 'svg') { | |
$link.setAttribute('href-lang', 'image/svg+xml'); | |
//tried the following | |
exportData = 'data:application/octet-stream;base64,' + encodeURIComponent(generator.getSVG()); | |
//exportData = 'data:application/octet-stream;base64,' + btoa(generator.getSVG()); | |
//exportData = 'data:image/svg+xml;base64,' + btoa(generator.getSVG()); | |
//exportData = 'data:image/svg+xml;' + encodeURIComponent(generator.getSVG()); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function() { | |
'use strict'; | |
var React = require('react/addons'); | |
var utils = require('../../javascripts/utils'); | |
var Image = module.exports = React.createClass({ | |
getInitialState : function() { | |
return { | |
imageShown : false |
NewerOlder