Skip to content

Instantly share code, notes, and snippets.

View evilbuck's full-sized avatar

Evil Buck evilbuck

  • evilbuck llc
  • Hobe Sound, FL
View GitHub Profile
@stalniy
stalniy / index.js
Created August 10, 2020 12:52
CASL + Objection
const { defineAbility } = require('@casl/ability');
const { rulesToQuery } = require('@casl/ability/extra');
const Knex = require('knex');
const { Model } = require('objection');
const { interpret } = require('@ucast/objection')
const { CompoundCondition } = require('@ucast/core')
const knex = Knex({
client: 'sqlite3',
connection: ':memory:'
@sagnitude
sagnitude / nvidia.md
Last active January 21, 2024 11:40 — forked from cavinsmith/nvidia.md
Nvidia GPUs sorted by CUDA cores

List of desktop Nvidia GPUS ordered by CUDA core count

I created it for those who use Neural Style

Guys, please add your hardware setups, neural-style configs and results in comments!

GPU CUDA cores Memory Processor frequency Memory Bandwidth (GB/sec)
Geforce GTX TITAN Z 5760 12 GB 705 / 876 673
@Atlas7
Atlas7 / coderpad_tdd_test_suites.js
Last active April 25, 2021 23:02
CoderPad - Mocha Chai Assert TDD Test Suite
// ***** Requirements
// Implement function sequence, which returns new n-size Array filled according to pattern.
//
// pattern may be:
// - a function that takes two: (element, index), one: (element) or any arguments (similar to map function), then filled running this function, in other words: function describes sequence,
// - number, string or any other object, then filled by copying, this object n-times.
//
// ****** Solution
@timharding
timharding / circle_ci_to_engine_yard_deployment.md
Last active December 14, 2016 12:54
CircleCI to Engine Yard Continuous Deployment

Configuring CircleCI to deploy to Engine Yard

Preamble

This is a brief description of how to get CircleCI builds deployed to an Engine Yard hosted staging environment automatically.

We're essentially asking CircleCI to execute commands on the Engine Yard gem to ask EY to deploy a Rails app.

CircleCI needs an SSH key and an API token to talk to Engine Yard, at that point you can execute the deploy command on the gem when the build succeeds.

@staltz
staltz / introrx.md
Last active May 3, 2024 13:00
The introduction to Reactive Programming you've been missing
@bregenspan
bregenspan / circle.yml
Created May 8, 2014 22:23
Testing a Circle CI build with Sauce Labs
## Customize the test machine
machine:
environment:
SAUCEUSER: [USERNAME HERE]
SAUCEKEY: [KEY HERE]
dependencies:
post:
- wget https://d2nkw87yt5k0to.cloudfront.net/downloads/sc-latest-linux.tar.gz && tar -xvf sc-latest-linux.tar.gz

Using pg.connect is the way to go in a web environment.

PostgreSQL server can only handle 1 query at a time per conenction. That means if you have 1 global new pg.Client() connected to your backend your entire app is bottleknecked based on how fast postgres can respond to queries. It literally will line everything up, queuing each query. Yeah, it's async and so that's alright...but wouldn't you rather multiply your throughput by 10x? Use pg.connect set the pg.defaults.poolSize to something sane (we do 25-100, not sure the right number yet).

new pg.Client is for when you know what you're doing. When you need a single long lived client for some reason or need to very carefully control the life-cycle. A good example of this is when using LISTEN/NOTIFY. The listening client needs to be around and connected and not shared so it can properly handle NOTIFY messages. Other example would be when opening up a 1-off client to kill some hung stuff or in command line scripts.

@CMCDragonkai
CMCDragonkai / angularjs_directive_attribute_explanation.md
Last active November 29, 2023 15:35
JS: AngularJS Directive Attribute Binding Explanation

AngularJS Directive Attribute Binding Explanation

When using directives, you often need to pass parameters to the directive. This can be done in several ways. The first 3 can be used whether scope is true or false. This is still a WIP, so validate for yourself.

  1. Raw Attribute Strings

    <div my-directive="some string" another-param="another string"></div>
@NV
NV / Readme.md
Last active May 28, 2023 20:42
Prepend the debugger statement to a function as easy as stopBefore('Element.prototype.removeChild'). Works in Chrome DevTools and Safari Inspector, doesn’t work in Firebug‘s and Firefox Developer Tools‘ console (I don’t know why). Works as a standalone script everywhere.

stopBefore.js

2min screencast

Examples

stopBefore(document, 'getElementById')
stopBefore('document.getElementById') // the same as the previous
stopBefore(Element.prototype, 'removeChild')
@duemir
duemir / luhn-node.js
Created March 22, 2013 12:56
JS Luhn algorithm for node - functional style!
var luhn = function (number) {
return number.split('').map(function (digit, index, arr) {
return (index % 2 !== arr.length % 2) ? parseInt(digit, 10) : 2 * digit;
}).reduce(function sum(val, cur, idx, arr) {
return val + (cur < 10 ? parseInt(cur, 10) : (String(cur).split('').reduce(sum, 0)));
}, 0) % 10;
};
exports.is_valid = function (number) {
return luhn(number) === 0;