This file contains 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
# | |
# This script scrapes your soldier statistics from Battlelog | |
# NOTE: This is just a very quick demonstration, it doesn't really do much as-is, besides | |
# authenticate to Battlelog and get you a dict of your soldier's statistics. | |
# There is no error handling, no anything. It will only work if everything goes well. | |
# | |
# | |
# Input your Origin username and password into the params dict below and it should work. | |
# | |
# In the very bottom, the stats dict will contain the data from the Battlelog JSON response. |
This file contains 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
#!/bin/bash | |
files=$(git diff --cached --name-only | grep '\.js$') | |
# Prevent ESLint help message if no files matched | |
if [[ $files = "" ]] ; then | |
exit 0 | |
fi | |
echo $files | xargs eslint |
This file contains 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
{-# LANGUAGE ScopedTypeVariables #-} | |
module DynLoad ( | |
loadSourceGhc, | |
execFnGhc | |
) where | |
import Control.Exception (throw) | |
import GHC hiding (loadModule) | |
import GHC.Paths (libdir) | |
import HscTypes (SourceError, srcErrorMessages) |
This file contains 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
(import | |
'(java.awt Rectangle Dimension Robot Toolkit) | |
'(java.awt.image BufferedImage) | |
'(java.io File IOException) | |
'(javax.imageio ImageIO)) | |
(defn take-screenshot [] | |
(let [screen (.getScreenSize (Toolkit/getDefaultToolkit)) | |
rt (new Robot) | |
img (.createScreenCapture rt (new Rectangle (int (.getWidth screen)) (int (.getHeight screen))))] |
This file contains 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
//guess where this fails. | |
this.x = function() { | |
hello(); | |
} | |
(foo || bar).call(); |
This file contains 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
//java | |
class X extends Y { | |
public X() { | |
super(); | |
} | |
public void method() { | |
} | |
public static staticMethod() { |
This file contains 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
someModule.service('something', function($rootScope) { | |
var emitter = $rootScope.$new(true); | |
var data = whateverStuffHere; | |
return { | |
onDataUpdated: function(callback) { | |
//by returning the result from $on, we get | |
//the ability to remove event listeners easily | |
return emitter.$on('update', callback); |
This file contains 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
//easy way to check if object has the expected "shape": | |
it('tests something', function() { | |
var expectedObject = { | |
some: 'prop', | |
values: 'here' | |
}; | |
var result = doStuff(); | |
assert.deepEqual(result, expectedObject); |
This file contains 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 moves = [].. | |
function makeMove() { | |
var m = moves.shift(); | |
if(!m) { | |
return everythingDone(); | |
} | |
setTimeout(function() { | |
activateButton(m); |
This file contains 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
//let's say all the moves are in this array | |
var moves = [...]; | |
moves.reduce(function(p, move) { | |
return p.then(activateWithDelay(move.button)) | |
.then(deactivateWithDelay(move.button)); | |
}, Promise.resolve()); |
NewerOlder