Skip to content

Instantly share code, notes, and snippets.

View felipecwb's full-sized avatar
🎧
🚀

Felipe Francisco felipecwb

🎧
🚀
View GitHub Profile
@felipecwb
felipecwb / switch-workspace.sh
Last active February 24, 2019 14:19
Gnome Switch to next active workspace!
#!/bin/bash
orientation=$1
if [ "$orientation" != "next" ] \
&& [ "$orientation" != "previous" ];
then
orientation="next"
fi
;$(function () {
$('.bootstrap-tagsinput').on('click', '.tag', function (event) {
var $tag = $(event.currentTarget);
var $input = $tag.parent().find('input');
var $field = $tag.parent().next('[data-role="tagsinput"]');
var value = $tag.text();
$field.tagsinput('remove', value);
$input.attr('size', value.length).val(value).trigger('focus');
@felipecwb
felipecwb / Xresources
Last active November 14, 2023 01:11
Xresources
!** Display Options
Xcursor.theme: Adwaita
!Xft.dpi: 92
Xft.autohint: 0
Xft.lcdfilter: lcddefault
Xft.hintstyle: hintslight
Xft.hinting: 1
Xft.antialias: 1
Xft.rgba: rgb
@felipecwb
felipecwb / countries.json
Last active June 9, 2017 13:36
Countries JSON
{
"countries": {
"country": [
{
"countryCode": "AD",
"countryName": "Andorra",
"capital": "Andorra la Vella",
"languages": "ca"
},
{
@felipecwb
felipecwb / small.vim
Last active May 22, 2017 21:27
small config to vim
" avoid close vim when delete buffer
function! <SID>BufcloseCloseIt()
let l:currentBufNum = bufnr("%")
let l:alternateBufNum = bufnr("#")
if buflisted(l:alternateBufNum)
buffer #
else
bnext
@felipecwb
felipecwb / volley.php
Last active May 24, 2017 17:12
Calculate different sequence of scores in a Volleyball match - https://www.hackerrank.com/contests/w1/challenges/volleyball-match
#!/usr/bin/env php
<?php
const MOD = 1e9 + 7;
function fact($n) {
return ($n > 1) ? $n * fact($n - 1) : 1;
}
function mpow($base, $exp, $mod) {
@felipecwb
felipecwb / stripSpecialChars.sql
Created August 30, 2016 21:24
Replace Special Chars
/** http://stackoverflow.com/questions/12652234/sql-query-to-remove-special-characters **/
DROP FUNCTION IF EXISTS `stripSpecialChars`;
DELIMITER ;;
CREATE FUNCTION `stripSpeciaChars`(`dirty_string` varchar(2048),allow_space TINYINT,allow_number TINYINT,allow_alphabets TINYINT,no_trim TINYINT) RETURNS varchar(2048) CHARSET utf8 DETERMINISTIC
BEGIN
/**
* MySQL function to remove Special characters, Non-ASCII,hidden characters leads to spaces, accents etc
* Downloaded from http://DevZone.co.in
* @param VARCHAR dirty_string : dirty string as input
@felipecwb
felipecwb / ps1.sh
Last active April 11, 2018 21:24
PS1 bash
# PS1
PROMPT_COMMAND='PWD_ABBREVIATION=$(p="${PWD#${HOME}}"; [ "${PWD}" != "${p}" ] && printf "~";IFS=/; for q in ${p:1}; do printf /${q:0:1}; done; printf "${q:1}")'
export PS1='`if [ $? = 0 ];then echo "\[\033[1;32m\]✔";else echo "\[\033[1;31m\]✘";fi` \[\033[1;34m\]\u\[\033[0m\]@\[\033[1;30m\]\h\[\033[0;33m\] ${PWD_ABBREVIATION}\[\033[0;35m\]$(__git_ps1) \[\033[1;31m\]>\[\033[0m\] '
# PS1
export PS1='`if [ $? = 0 ];then echo "\[\033[1;32m\]✔";else echo "\[\033[1;31m\]✘";fi` \[\033[1;30m\]\u \[\033[1;34m\]\w\[\033[0;35m\]$(__git_ps1) \[\033[1;31m\]>\[\033[0m\] '
@felipecwb
felipecwb / git-youtrack.sh
Created January 5, 2016 21:00
Hack to list the task and commits in branch for analysis.
#!/bin/sh
tags=()
while read line; do
tags+=($line);
done <<< "$(git tag | sort -V | tail -n2)";
tag1=${1:-${tags[0]}}
tag2=${2:-${tags[1]}}
@felipecwb
felipecwb / pascalTree.js
Last active September 15, 2016 12:23
Arvore de Pascal in JavaScript
#!/usr/bin/env node
"use strict";
String.PAD_LEFT = 1;
String.PAD_RIGHT = 2;
String.PAD_BOTH = 3;
String.prototype.pad = function(len, pad, dir) {
var str = this;
if (typeof(len) == "undefined") { len = 0; }
if (typeof(pad) == "undefined") { pad = ' '; }