Skip to content

Instantly share code, notes, and snippets.

View zvictor's full-sized avatar
🐥

Victor Duarte zvictor

🐥
View GitHub Profile
#!/bin/bash
sleep 1
DISPLAY=":0.0"
HOME=/home/zvictor/
XAUTHORITY=$HOME/.Xauthority
export DISPLAY XAUTHORITY HOME
usbkbd_ids=`xinput -list | grep "Keyboard" | awk -F'=' '{print $2}' | cut -c 1-2`
usbkbd_layout="dk"
for ID in $usbkbd_ids; do
gsettings set org.gnome.settings-daemon.plugins.keyboard active false
@zvictor
zvictor / FilterStyle.js
Created September 26, 2014 09:18
FilterStyle: Display/hidden elements by js according to class selectors
function FilterStyle(name, show) {
"use strict";
// @see http://stackoverflow.com/a/8630641/599991
// @see http://www.happycode.info/create-css-classes-with-javascript/
this.name = name;
this.show = show;
if(show !== undefined)
this.update();
<!DOCTYPE html>
<html>
<head>
<meta charset='utf-8' />
<link href='http://fullcalendar.io/js/fullcalendar-2.3.1/fullcalendar.css' rel='stylesheet' />
<link href='http://fullcalendar.io/js/fullcalendar-2.3.1/fullcalendar.print.css' rel='stylesheet' media='print' />
<script src='http://cdnjs.cloudflare.com/ajax/libs/moment.js/2.9.0/moment.min.js'></script>
<script src='http://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js'></script>
<script src='http://fullcalendar.io/js/fullcalendar-2.3.1/fullcalendar.js'></script>
@zvictor
zvictor / models.py
Created November 9, 2011 11:24
An example how to connect userena with django-social registration.
from socialregistration.signals import connect as profile_connect
from userena.managers import ASSIGNED_PERMISSIONS
@receiver(socialregistration_signals.connect, sender = FacebookProfile, dispatch_uid = 'facebook.connect')
def social_connect_callback(sender, user, profile, client, **kwargs):
"""
Create a profile for this user after connecting
"""
# Create a userena user.
@zvictor
zvictor / django-crossdomainxhr-middleware.py
Created June 10, 2012 20:50 — forked from vicalejuri/django-crossdomainxhr-middleware.py
Middlware to allow's your django server to respond appropriately to cross domain XHR (postMessage html5 API).
import re
from django.utils.text import compress_string
from django.utils.cache import patch_vary_headers
from django import http
try:
import settings
XS_SHARING_ALLOWED_ORIGINS = settings.XS_SHARING_ALLOWED_ORIGINS
@zvictor
zvictor / aggregation.js
Created August 6, 2013 17:08
Aggregation (distinct, aggregate and mapReduce) extension for Meteor's Smart-collection
var Future, path, _dummyCollection_, _futureWrapper;
path = Npm.require("path");
Future = Npm.require(path.join("fibers", "future"));
_dummyCollection_ = new Meteor.Collection('__dummy__');
_futureWrapper = function(collection, commandName, args) {
var col, collectionName, future, result,
_this = this;
col = (typeof collection) === "string" ? _dummyCollection_ : collection;
collectionName = (typeof collection) === "string" ? collection : collection._name;
@zvictor
zvictor / modulus.npm.log
Created August 8, 2013 18:51
npm log from Modulus
$ modulus deploy
Welcome to Modulus
You are logged in as zvictor
[?] Are you sure you want to use project slirp? (yes)
Compressing project...
636.8 KB written
Uploading project...
Upload progress [===================] 100%
Deploying Project...
INFO: Attaching persistent storage.
@zvictor
zvictor / react.css.js
Created June 3, 2016 17:23
List of css modules for React to be evaluated at http://www.timqian.com/star-history/
var list = ['Khan/aphrodite',
'martinandert/babel-plugin-css-in-js',
'rtsao/csjs',
'webpack/css-loader',
'jareware/css-ns',
'krasimir/cssx',
'colingourlay/hyperstyles',
'j2css/j2c',
'petehunt/jsxstyle',
'FormidableLabs/radium',
box: ubuntu:16.04
services:
- mongo # http://devcenter.wercker.com/docs/services/mongodb.html
initial-build:
steps:
- script:
name: start apt-get
code: |
apt-get update
@zvictor
zvictor / Git alias
Last active November 16, 2016 16:13
A simplified version of the git commands found on http://www.praqma.com/stories/a-pragmatic-workflow/
# Based on http://www.praqma.com/stories/a-pragmatic-workflow/
#
# Add this to your git configurations using:
# $ git config --global --edit
[alias]
issue-branch = "!f() { MATCH=#$1:; ghi show $1 2>/dev/null | grep $MATCH | sed s/$MATCH/$1/g | sed 's/ /-/g' | sed s/[:\\']//g; }; f"
issue-wip = "!f() { ghi label $1 'in progress'; }; f"
work-on = "!f() { BRANCH=`git issue-branch $1`; git fetch origin; git checkout $BRANCH 2> /dev/null || git checkout -b $BRANCH; git issue-wip $1; ghi assign $1; }; f"