Skip to content

Instantly share code, notes, and snippets.

View johntron's full-sized avatar

John Syrinek johntron

View GitHub Profile
@johntron
johntron / gist:dd01d7b6b25bb8586141
Last active August 29, 2015 14:02
Find all untranslated strings
johntron> grasp ':matches(assign[left.prop=#strings],var-dec[id=#strings]) obj.props[val=literal].val' -r components-spirent/
components-spirent/endpoint-view-model/index.js:79: "Field is required": "Field is required",
components-spirent/endpoint-view-model/index.js:80: "Must be less than 4,096": "Must be less than 4,096",
components-spirent/endpoint-view-model/index.js:81: "Must be an IP address": "Must be an IP address",
components-spirent/endpoint-view-model/index.js:82: "Must be greater than 0": "Must be greater than 0",
components-spirent/endpoint-view-model/index.js:83: "Must be less than 128": "Must be less than 128",
components-spirent/endpoint-view-model/index.js:84: "Must be less than or equal to 512": "Must be less than or equal to 512",
components-spirent/endpoint-view-model/index.js:85: "Must be an integer": "Must be an integer",
components-spirent/endpoint-view-model/index.js:86: "An endpoint already exists with this name": "An endpoint al
Reporting server status on {{2014,5,28},{19,6,27}}
Status of node rabbit@tomahawk ...
[{pid,1262},
{running_applications,[{rabbit,"RabbitMQ","2.6.1"},
{os_mon,"CPO CXC 138 46","2.2.7"},
{sasl,"SASL CXC 138 11","2.1.10"},
{mnesia,"MNESIA CXC 138 12","4.5"},
{stdlib,"ERTS CXC 138 10","1.17.5"},
{kernel,"ERTS CXC 138 10","2.14.5"}]},
@johntron
johntron / gist:768927e0b863dbb06672
Last active August 29, 2015 14:01
The author of the code below intended the "small" text below to be 75%, but instead it is 12px. Update the CSS so it appears as intended.
<!DOCTYPE html>
<body>
<style>
body { font-size: 12px; }
div .caption {
font-size: 12px;
}
.small {
@johntron
johntron / gist:16aababf50db66b98ea8
Last active August 29, 2015 14:01
The author of the following code intended "You are on the Home page" to appear in a dialog when the button is clicked. It doesn't work this way. Why not?
<button>Which page am I on?</button>
<script>
var Page = {
title: 'Home',
init: function() {
document.querySelector('button').onclick = function () {
alert('You are on the ' + this.title + ' page');
};
}
def pummel_session(request):
import hashlib
import random
import time
now = time.time()
while time.time() < now + 60:
request.session[hashlib.md5().hexdigest()] = hashlib.md5().hexdigest()
request.session.changed()
@johntron
johntron / trig_solver.js
Created April 29, 2014 13:23
Tabata 29 April 2014 - Trig triangle solver
/*
http://www.reddit.com/r/dailyprogrammer/comments/2451r5/4282014_challenge_160_easy_trigonometric_triangle/
Solutions:
C = 90
f(a,b) = (a**2 + b**2)**-2 = c
f(a,c) = (c**2 - a**2)**-2 = b
f(b,c) = (c**2 - b**2)**-2 = a
*/
// jQuery's .trigger() doesn't fire handlers bound with the native .addEventListener() - here's a workaround for modern browsers (IE 9+)
var $el = $('.my-el'),
e;
try {
e = new Event('change');
} catch (unused) {
var read = require('fs').readFileSync;
module.exports = function (builder) {
builder.hook('before scripts', function (pkg, next) {
var config = pkg.config,
tests = config.tests,
development = config.development;
if (!tests) return next();
@johntron
johntron / gist:8284939
Last active January 2, 2016 09:39
Update the line below so this code alerts "bar" instead of "foo".
var message = "foo";
function show() {
alert(message);
}
// Insert your code here
show();
@johntron
johntron / gist:8284931
Last active January 2, 2016 09:39
This code should update the <div> with the value the user entered when "update" is clicked, but it does not. Why, and how do you fix this? Assume you cannot change the show() function.
<div class="number"></div>
<input type="text" /><button class="update">update</button>
<script type="text/javascript">
var $number = document.querySelector('.number');
var $input = document.querySelector('input');
function show() {
$number.innerHTML = this.value;
}