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 / MyActionProvider.java
Created October 16, 2015 19:56
Custom Action Provider to show just a submenu to a menu item
public class MyActionProvider extends ActionProvider {
private Context mContext;
public MyActionProvider(Context context) {
super(context);
mContext = context;
}
@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 / 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 / myenvs
Created November 17, 2015 18:28
Myenvs
function myenvs() {
if [[ $# -ne 1 ]]; then
export $(cat .env | xargs)
else
export $(cat $1 | xargs)
fi
}
@sibelius
sibelius / getdb.sh
Last active October 9, 2018 02:58
Get sqlite Android app database without root
#!/bin/bash
adb shell "run-as com.example chmod 666 databases/db.name"
adb pull /data/data/com.example/databases/db.name .
@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
@interface Person : NSObject <RCTBridgeModule>
@end
@implementation Logger
RCT_EXPORT_MODULE()
RCT_EXPORT_METHOD(greet:(NSString *)name)
{
NSLog(@"Hi, %@!", name);
@sibelius
sibelius / git aliases
Created April 20, 2016 20:04
Git aliases
[alias]
lg1 = log --graph --abbrev-commit --decorate --date=relative --format=format:'%C(bold blue)%h%C(reset) - %C(bold green)(%ar)%C(reset) %C(white)%s%C(reset) %C(dim white)- %an%C(reset)%C(bold yellow)%d%C(reset)' --all
lg2 = log --graph --abbrev-commit --decorate --format=format:'%C(bold blue)%h%C(reset) - %C(bold cyan)%aD%C(reset) %C(bold green)(%ar)%C(reset)%C(bold yellow)%d%C(reset)%n'' %C(white)%s%C(reset) %C(dim white)- %an%C(reset)' --all
lg = log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit
co = checkout
ec = config --global -e
cob = checkout -b
cm = !git add -A && git commit -m
st = status
@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 => {