Skip to content

Instantly share code, notes, and snippets.

View kbiedrzycki's full-sized avatar
🤔
Are you sure it should work this way?

Kamil Biedrzycki kbiedrzycki

🤔
Are you sure it should work this way?
View GitHub Profile
@kbiedrzycki
kbiedrzycki / inject_router.js
Created March 8, 2017 09:58
Router injection in ember tests
const StubInstance = Ember.Object.extend({
didCreateRootView () {},
});
this.registry.register('-application-instance:main', StubInstance);
const router = this.container.lookup('router:main');
router.startRouting(true);
@kbiedrzycki
kbiedrzycki / math.js
Created September 5, 2016 16:32
Example math expressions
// valid math scripts
// Example 1
x = 10 // this is mathjs variable, not plain JS
for (i = 0; i < x; i++) {
if (x >= 10) {
sin(x * pi) // mathjs sin function, pi is mathjs constant
}
@kbiedrzycki
kbiedrzycki / disable_notes.js
Created August 30, 2016 10:44
Disable notes on github
Array.from(document.querySelectorAll('.js-toggle-file-notes')).forEach((element) => element.click())
@kbiedrzycki
kbiedrzycki / isPrime.js
Last active July 15, 2016 08:45
Function for checking if number is prime (matching regular expression of unary value)
module.exports = function(value) {
const primeVerifyExpression = /^1?$|^(11+?)\1+$/;
const unaryValue = '1'.repeat(value);
return !primeVerifyExpression.test(unaryValue);
}