Skip to content

Instantly share code, notes, and snippets.

@badbabykosh
badbabykosh / hash_of_hashes.rb
Created December 9, 2012 18:28
Attempting to build hash of hashes
def build_virtual_boards_hash(board, player)
virtual_boards_hash = {}
new_board_hash = {}
virtual_board = board.dup
empty_spaces_on_board = virtual_board.grid.select{ |k, v| v == " " }.keys
index_mark = 'VB'+empty_spaces_on_board.length.to_s
while empty_spaces_on_board.length >= 1
empty_spaces_on_board.each do |empty_space_symbol|
@badbabykosh
badbabykosh / set-interval-spec.js
Last active September 4, 2015 00:16 — forked from pkananen/set-interval-spec.js
testing setInterval with Jasmine using a Mock Clock
describe('createIntervalCallback', function() {
var sut = $.clockTest;
it('calls setInterval with callback() at a delay of 7000 ms', function() {
spyOn(sut, 'callback');
jasmine.Clock.useMock();
sut.createIntervalCallback();
jasmine.Clock.tick(7000);
@badbabykosh
badbabykosh / diff-ang2-and-ang4.md
Last active August 25, 2017 04:01
Angular2 vs Angular4

What is the diff between Angular2 and Angular4?

Well there is no path breaking change that means Angular 4 is not a complete rewrite of Angular 2 .Google has adapted SEMVER (Semantic versioning) approach for it’s Angular Framework.Why not Angular 3?Due to misalignment of router package version . As @angular/router was using v3.3 already , so they switch to Angular 4 Finally .What has Changed?Angular team has laid emphasis on making angular apps more faster,compact .Under the Hood ChangesNew changes reduce the size of the generated code for your components by around 60% in most cases.The more complex your templates are, the higher the savings.Fa

@badbabykosh
badbabykosh / vpn.md
Created May 4, 2020 01:08 — forked from joepie91/vpn.md
Don't use VPN services.

Don't use VPN services.

No, seriously, don't. You're probably reading this because you've asked what VPN service to use, and this is the answer.

Note: The content in this post does not apply to using VPN for their intended purpose; that is, as a virtual private (internal) network. It only applies to using it as a glorified proxy, which is what every third-party "VPN provider" does.

  • A Russian translation of this article can be found here, contributed by Timur Demin.
  • A Turkish translation can be found here, contributed by agyild.
  • There's also this article about VPN services, which is honestly better written (and has more cat pictures!) than my article.
@badbabykosh
badbabykosh / trace.rb
Created July 10, 2021 18:44 — forked from bendilley/trace.rb
Get a trace from a 'stack too deep' error in Rails
$enable_tracing = false
#$trace_out = File.open(Rails.root + 'trace.txt', 'w')
set_trace_func proc { |event, file, line, id, binding, classname|
if $enable_tracing && event == 'call'
#$trace_out.puts "#{file}:#{line} #{classname}##{id}"
raise "crash me" if caller_locations.length > 500
end
}
@badbabykosh
badbabykosh / countries.json
Created January 4, 2022 08:21
country json
[{"name":{"common":"Aruba","official":"Aruba","native":{"nld":{"official":"Aruba","common":"Aruba"},"pap":{"official":"Aruba","common":"Aruba"}}},"tld":[".aw"],"cca2":"AW","ccn3":"533","cca3":"ABW","cioc":"ARU","independent":false,"status":"officially-assigned","unMember":false,"currencies":{"AWG":{"name":"Aruban florin","symbol":"\u0192"}},"idd":{"root":"+2","suffixes":["97"]},"capital":["Oranjestad"],"altSpellings":["AW"],"region":"Americas","subregion":"Caribbean","languages":{"nld":"Dutch","pap":"Papiamento"},"translations":{"ces":{"official":"Aruba","common":"Aruba"},"deu":{"official":"Aruba","common":"Aruba"},"est":{"official":"Aruba","common":"Aruba"},"fin":{"official":"Aruba","common":"Aruba"},"fra":{"official":"Aruba","common":"Aruba"},"hrv":{"official":"Aruba","common":"Aruba"},"hun":{"official":"Aruba","common":"Aruba"},"ita":{"official":"Aruba","common":"Aruba"},"jpn":{"official":"\u30a2\u30eb\u30d0","common":"\u30a2\u30eb\u30d0"},"kor":{"official":"\uc544\ub8e8\ubc14","common":"\uc544\ub8e8\ubc14
@badbabykosh
badbabykosh / react-snippets-codes.md
Last active December 19, 2022 19:24
react snippets commands

(this is just a copy of the commands so i can pull them up fast in gist) (go here for the repo... https://github.com/badbabykosh/js-react-redux-yasnippets)

Enter "yas-describe-tables" to see all available snippet commands

NOTE: execute command via - hold tab key

Snippets

Below is a list of all available snippets and the triggers of each one. The means the TAB key.

let NETWORK_PRESETS = {
'GPRS': {
'offline': false,
'downloadThroughput': 50 * 1024 / 8,
'uploadThroughput': 20 * 1024 / 8,
'latency': 500
},
'Regular2G': {
'offline': false,
'downloadThroughput': 250 * 1024 / 8,
@badbabykosh
badbabykosh / emacs_indium_debugging.md
Created January 25, 2023 21:13
emacs debugging with indium

EMACS JS DEBUGGING WITH INDIUM

  1. indium requires a config file to be setup .indium.json
  2. M-x indium-launch

The .indium.json file can contain as many configurations as needed, and mix any supported configuration types.

The currently supported type values are "chrome" and "node".

The root directory of the source files is by default set to the directory where this .indium.json file is placed, but it can be overridden with the root (or the webRoot alias) option: