Skip to content

Instantly share code, notes, and snippets.

View MarcoPolo's full-sized avatar
🌠
Gradatim

Marco Munizaga MarcoPolo

🌠
Gradatim
View GitHub Profile
@MarcoPolo
MarcoPolo / prop-enumerations.js
Created February 11, 2019 19:06
Enumerate through props quickly
function seedPossibilitiesCount(seed) {
if (Array.isArray(seed)) {
return seed.length
} else if (typeof seed === 'object' && !!seed && seed.constructor === Object) {
let count = 1
Object.keys(seed).forEach(k => {
count *= seedPossibilitiesCount(seed[k])
})
return count
}
var http = require('http')
var fs = require('fs')
var server = http.createServer(function(request, response) {
var req = request
response.writeHead(200, {'Content-Type': 'textplain'})
if (req.method === 'POST') {
var body = ''
req.on('data', function(data) {
body += data
})
@MarcoPolo
MarcoPolo / gist:db5ffb4ca5f14d42d5f242a6af0b2524
Last active November 10, 2016 05:12
Traverse inverse dependency react native
counts = {}
a = {} // your inverse dep map
// helper to return a string of n spaces... omg this is left pad
function s (n) { let k = ''; for (i = 0; i<n; i++) {k = k + ' '}; return k}
function f (k, ttl, indent, seen) {
if (seen[k]) { console.warn('circular dep found', k, seen) }
let kl = (''+k).length; counts[k] = (counts[k] || 0) + 1 ;return (ttl > 0 && a[k] && a[k].length ? k + ' -> ' + a[k].map(i => f(i, ttl - 1, indent + s(4+kl), Object.assign(seen, {[k]: true}))).join('\n' + s(kl + 4) + indent) : k)
}
" vim: ts=4 sw=4 et
function! neomake#makers#ft#rust#EnabledMakers()
return ['rustc']
endfunction
function! neomake#makers#ft#rust#rustc()
return {
\ 'args': ['rustc', '-Zno-trans'],
\ 'exe': 'cargo',
@MarcoPolo
MarcoPolo / sad.md
Created March 18, 2015 23:00
Shit ios devs say

On putting an .xib into storyboard

Add a new UIViewController to the storyboard. Remove its main view so that the view controller is empty. Set the Class of the view controller (in the Identity Inspector) to that of your nib's File's Owner. Also make sure the .h and .m files are added to your project already.

Now open the nib, select the top-most view and press Cmd-C to copy it to the clipboard. Switch to the storyboard, select that new, empty view controller. Press Cmd-V to paste the contents of the nib into this view controller.

You may have to reconnect all the outlets and actions, but at least you don't have to do the layout again. :-)

from

### Keybase proof
I hereby claim:
* I am marcopolo on github.
* I am marcopolo (https://keybase.io/marcopolo) on keybase.
* I have a public key whose fingerprint is D308 20E9 C435 0FF7 11AB B8F0 F5D5 EDF3 AAA6 0570
To claim this, I am signing this object:
@MarcoPolo
MarcoPolo / gist:11103741
Last active August 29, 2015 14:00
Training data
{"like":["1xx4ki_380.jpg","1xx4ki_391.jpg","1xx4ki_160.jpg","1xx4ki_150.jpg","1xx4ki_271.jpg","1xx4ki_161.jpg","1xx4ki_194.jpg","1xz78t_141.jpg","1xx4ki_360.jpg","1xx4ki_151.jpg","1xx4ki_272.jpg","1xx4ki_393.jpg","1xx4ki_162.jpg","1xx4ki_283.jpg","1xx4ki_294.jpg","1xx4ki_195.jpg","1xz78t_120.jpg","1xz78t_131.jpg","1xz78t_142.jpg","1xx4ki_350.jpg","1xx4ki_361.jpg","1xx4ki_262.jpg","1xx4ki_152.jpg","1xx4ki_394.jpg","1xx4ki_284.jpg","1xx4ki_185.jpg","1xx4ki_196.jpg","1xz78t_143.jpg","1xx4ki_450.jpg","1xx4ki_120.jpg","1xx4ki_362.jpg","1xx4ki_373.jpg","1xx4ki_263.jpg","1xx4ki_153.jpg","1xx4ki_285.jpg","1xz78t_0.jpg","1xx4ki_175.jpg","1xx4ki_296.jpg","1xz78t_110.jpg","1xz78t_121.jpg","1xz78t_132.jpg","1xx4ki_451.jpg","1xx4ki_341.jpg","1xx4ki_352.jpg","1xx4ki_363.jpg","1xx4ki_253.jpg","1xx4ki_396.jpg","1xx4ki_286.jpg","1xz78t_1.jpg","1xx4ki_297.jpg","1xz78t_122.jpg","1xz78t_133.jpg","1xx4ki_210.jpg","1xx4ki_331.jpg","1xx4ki_100.jpg","1xx4ki_221.jpg","1xx4ki_342.jpg","1xx4ki_111.jpg","1xx4ki_353.jpg","1xx4ki_364.jpg"
(defn play-time-travel [entities]
(doseq [e entities
:let [actions (:actions @e)
prev-actions (:prev-actions @e)]]
(when (and (actions :travel-back)
(not (prev-actions :travel-back)))
;;play sound
)
(swap! e assoc :prev-actions actions)
(deffacts cities
(city-list tallahassee lake-city gainesville jacksonville st-augustine ocala orlando tampa west-palm ft-myers miami key-west)
(city name tallahassee neighbors lake-city 2)
(city name lake-city neighbors tallahassee 2 jacksonville 1 gainesville 1)
(city name gainesville neighbors lake-city 1 ocala 1 st-augustine 1)
(city name jacksonville neighbors lake-city 1 st-augustine 1)
(city name st-augustine neighbors jacksonville 1 gainesville 1 orlando 2 west-palm 3)
(city name ocala neighbors gainesville 1 orlando 1 tampa 2)
(city name orlando neighbors ocala 1 st-augustine 2 tampa 1 west-palm 3)
(city name tampa neighbors ft-myers 2 orlando 1 ocala 2)
@MarcoPolo
MarcoPolo / gist:9636822
Created March 19, 2014 07:11
How to find the smallest number in a set of facts
(assert
(foo 3)
(foo 4)
(foo 6)
(foo 9)
(foo 2)
(foo 5))
(defrule init-lowest
(not (lowest-foo ?))