Skip to content

Instantly share code, notes, and snippets.

View sibelius's full-sized avatar
🦈
give me a feedback https://entria.feedback.house/sibelius

Sibelius Seraphini sibelius

🦈
give me a feedback https://entria.feedback.house/sibelius
View GitHub Profile
@sibelius
sibelius / mongodb_backup.py
Last active August 29, 2015 14:16
Mongodb backup gist
#!/usr/bin/env python
import subprocess
import os
import tarfile
import shutil
import glob
from datetime import datetime
import argparse
@sibelius
sibelius / line_profiler.py
Created October 21, 2015 19:04
Line Profiler decorator, it works on pure Python or Web frameworks like Flask or Django
try:
from line_profiler import LineProfiler
def do_profile(follow=[]):
def inner(func):
def profiled_func(*args, **kwargs):
try:
profiler = LineProfiler()
profiler.add_function(func)
for f in follow:
profiler.add_function(f)
@sibelius
sibelius / gist:7790ef72699683eaae6b
Created January 27, 2016 19:10
Frontend exercise - Async
Exercise to hire new front-end in the future
You have a list of string (var regions = ['Brazil', 'SP', 'São Carlos', 'Caaso']
Each one of these strings represents a region, the first region is the parent (includes) the second region, and so on.
You have the following POST route /region, that accepts name and parentId, and return the ID of the region created
Write a program in **JS** that saves all the regions taking into consideration their hierarchy:
Example of algorithm:
Save Brasil
@sibelius
sibelius / transform.js
Created April 21, 2016 10:36
Convert import React, { Component } from 'react-native' to import React, { Component } from 'react'
// find and update all import React, { Component } from 'react-native'
root
.find(j.ImportDeclaration, {
source: {
value: 'react-native'
}
})
.filter(({node}) => {
// check React or { Component } from 'react-native'
const nodes = node.specifiers.filter(imports => {
@sibelius
sibelius / datepicker-mask.directive.js
Created October 19, 2015 15:49
Workaround to have a datepicker with mask
//Immediately Invoked Function Expression (IIFE)
(function() {
'use strict';
angular
.module('app')
.directive('datepickerMask', datepickerMask);
function datepickerMask() {
var directive = {
@sibelius
sibelius / find_hostname.bash
Created May 20, 2016 11:49
hostname command on an OSX
hostname
@sibelius
sibelius / .babelrc
Created May 9, 2016 19:37
PubNub-cli - simulate a message from a friend
{
"presets": ["es2015", "stage-0"]
}
@interface Person : NSObject <RCTBridgeModule>
@end
@implementation Logger
RCT_EXPORT_MODULE()
RCT_EXPORT_METHOD(greet:(NSString *)name)
{
NSLog(@"Hi, %@!", name);
@sibelius
sibelius / prepareMongooseObject.js
Created September 7, 2016 21:31
prepareMongooseObject to use with jest snapshot
export function prepareMongooseObject(obj) {
const placeholder = {};
let counter = 0;
const objectIdToNumber = {};
// TODO - find a better way to extract objects id
Object.keys(obj.toJSON()).map((key) => {
const value = obj[key];
@sibelius
sibelius / prepareObjectSnapshot.js
Created September 15, 2016 21:39
Prepare an object to be snapshoted by jest
/**
* Prepare an object to be snapshoted by jest
* replace objectID
* replace datetime
* frozen same specific keys
* @param obj
* @returns {{}}
*/
export function prepareObject(obj, frozenKeys = []) {
const placeholder = {};