Skip to content

Instantly share code, notes, and snippets.

Ates Goral atesgoral

Block or report user

Report or block atesgoral

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@atesgoral
atesgoral / validate_upc.js
Last active Jul 5, 2019
UPC-12 validation
View validate_upc.js
['101010101012','614141000036','036000241457','613119000030','614141000035','036000241450','614141000030']
.map(upc=>!(upc.split``.reduce((u,p,c)=>u+p*(3+c*2&3),0)%10))
// [true, true, true, true, false, false, false]
View softer_delete_all_dependents.rb
module SofterDeleteAllDependents
extend ActiveSupport::Concern
included do
before_destroy :softer_delete_associations, prepend: true
end
private
def softer_delete_associations
@atesgoral
atesgoral / keybinding.json
Last active May 3, 2018
Visual Studio Code custom task for running current MiniTest
View keybinding.json
{ "key": "shift+ctrl+t", "command": "workbench.action.tasks.runTask", "args": "Run current MiniTest" }
View Blockstack ID proof
Verifying my Blockstack ID is secured with the address 1PZj88MLiKCR86H8JiSgu2e26fxpR17Rht https://explorer.blockstack.org/address/1PZj88MLiKCR86H8JiSgu2e26fxpR17Rht
@atesgoral
atesgoral / github_totp.js
Created Apr 22, 2016
GitHub TOTP token generation
View github_totp.js
const GitHubApi = require('github');
const speakeasy = require('speakeasy');
github.authenticate({
type: 'basic',
username: process.env.GITHUB_USERNAME,
password: process.env.GITHUB_PASSWORD
});
const token = speakeasy.totp({
@atesgoral
atesgoral / 1-original.js
Last active Mar 6, 2016
Syntactical sugar experiments against promise indentation hell
View 1-original.js
return getFoo()
.then(foo => {
return getBar(foo)
.then(bar => {
return getBaz(foo, bar)
.then(baz => {
return getQux(foo, bar, baz);
});
});
});
View onename
Verifying that +atesgoral is my blockchain ID. https://onename.com/atesgoral
@atesgoral
atesgoral / js-style-guide.md
Last active Sep 6, 2015
Deterministic JavaScript Style Guide
View js-style-guide.md

Deterministic JavaScript Style Guide

This the style that I use and proselytize. Everything is derived from just a handful of core rules:

  1. 4 spaces for indentation.
  2. Code block opening curly brackets (braces) are on the same line (as function, for, if, etc.)
  3. Add spaces around operators and statements.
  4. Add spaces inside brackets for array and object literals.
  5. Don't add spaces inside parenthesis.
View keybase.md

Keybase proof

I hereby claim:

  • I am atesgoral on github.
  • I am atesgoral (https://keybase.io/atesgoral) on keybase.
  • I have a public key whose fingerprint is 8D59 5FAD E029 0A18 3357 08BF EA57 0ED6 6ACF 59B3

To claim this, I am signing this object:

You can’t perform that action at this time.