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
package com.davelnewton.exceptions; | |
import javax.swing.*; | |
import java.awt.*; | |
import java.awt.event.ActionEvent; | |
import java.awt.event.ActionListener; | |
import java.text.DecimalFormat; | |
import static java.lang.Math.abs; |
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
/** | |
* A function that takes a template and grammatical options ('gender', 'person', 'name') and returns the computed string. | |
* See below for examples. | |
* | |
* See wikipedia for more on grammar: | |
* http://en.wikipedia.org/wiki/English_personal_pronouns | |
* http://en.wikipedia.org/wiki/Grammatical_conjugation | |
*/ | |
function personalize(template, options) { | |
var GENDERS = ['neutral', 'female', 'male']; |
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
const sinon = require('sinon') | |
function Example() {} | |
Example.prototype.someFunc1 = function () { return 42; } | |
Example.prototype.func = function (fn) { return fn(); } | |
const example = new Example() | |
console.log(example.func(example.someFunc1)) | |
// >> 42 |
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
function pluralize(dur, s) { | |
var ret = false; | |
if (dur > 0) { | |
ret = dur + ' ' + s; | |
if (dur > 1) { | |
ret += 's'; | |
} | |
} |
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
public static String createId() { | |
// Test by mocking `checkConfigs()` and make | |
// sure `generateRandomId()` is called | |
if (!checkConfigs()) { | |
return generateRandomId(); | |
} | |
HttpURLConnection connection = accessProv(); | |
try { | |
// Test in two ways: |
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
package mygradeloops.java; | |
public class MyGradeLoopsJava { | |
public static void main(String[] args) { | |
for (int x = 1; x <= 20; x++) { | |
System.out.println("Please enter a number: "); | |
System.read.in(20); | |
System.out.println "Thank you."; | |
if (x == 10) continue; | |
System.out.println "Halfway there! Keep up the good work!";" |
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
require 'memory_profiler' | |
report = MemoryProfiler.report do | |
h = {} | |
prng = Random.new | |
10000.times { | |
n1 = prng.rand(200) | |
n2 = prng.rand(200) | |
h[[n1, n2]] = prng.rand(200) |
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
@atom-ui-font-size: 10px; | |
html, body, .tree-view, .status-bar, .tab-bar .tab { | |
font-size: @atom-ui-font-size; | |
} |
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
> yesterday = DateTime.yesterday() | |
=> Fri, 10 Jul 2015 | |
> yesterday.beginning_of_week | |
=> Sun, 05 Jul 2015 | |
> (yesterday.beginning_of_week - 1.days).beginning_of_week | |
=> Sun, 28 Jun 2015 | |
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
For the blog post at: | |
http://buckybits.blogspot.com/2015/06/coffeescript-iifes.html |