Skip to content

Instantly share code, notes, and snippets.

View kavichu's full-sized avatar
🎯
Focusing

Luis Valdés kavichu

🎯
Focusing
View GitHub Profile
@kavichu
kavichu / recursion.js
Created September 10, 2015 12:48
A recursive task to update DOM elements that are loaded dynamically.
// how many seconds does the interval have 'time' seconds
var time = 5;
// The recursive call will be made every 'timeout' milliseconds
var timeout = 500;
// this task will be executed in every call to 'recursive'
var task = function(level){
console.log("Hello world, level is " + level);
};

Keybase proof

I hereby claim:

  • I am lvlds on github.
  • I am lvlds (https://keybase.io/lvlds) on keybase.
  • I have a public key whose fingerprint is 8B84 AD78 BD6C 0EB1 F36A D72B 611A 8C55 035C 0668

To claim this, I am signing this object:

ratings = [[3,4], [3,3,3,4], [4]]
def ratingThreshold(threshold, ratings):
avgF = lambda x: [ sum([ e for e in x[0] ]) / float(len(x[0])), x[1] ]
average = map(avgF, zip(ratings, range( len(ratings) ) ) )
return [i[1] for i in average if i[0] < threshold]
print(ratingThreshold(3.5, ratings))
@kavichu
kavichu / npm_workspace_clean.sh
Created February 28, 2016 19:07
Add to cat npm_workspace_clean.sh >> ~/.bashrc.
function ds_tree {
for dir in $(find . -maxdepth 1 -type d )
do
du -sh $dir;
done
}
function npm_workspace_clean_recursive {
find . -maxdepth 2 -name "node_modules" -exec rm -rf {} \;
}
@kavichu
kavichu / workflow-properties.groovy
Created April 4, 2016 18:05
JIRA Workflow Properties using ScriptRunner plugin
/*
Autor: Luis Valdes
Fecha: 27/01/2016
*/
import com.atlassian.jira.workflow.WorkflowManager
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.user.ApplicationUser
workflowManager = ComponentAccessor.getWorkflowManager()
@kavichu
kavichu / latinoware2016.js
Created October 20, 2016 18:04
Docker + Jenkins + NodeJS + DigitalOcean
let shine = () => {
let table = jQuery(`table[id^="table"]`);
let filters = jQuery(`#ctl0_ctl1 > div.content-viewprogram.content > fieldset > div > label:nth-child(1) > span`);
const td = jQuery(`table tbody tr:nth-child(1) td:nth-child(9)`);
const cellContent = td.find("div.CellContent");
td.css("background-color"," black");
cellContent.css("background-color"," black");
cellContent.css("font-size", "18px");
table.css("width", "60%");
@kavichu
kavichu / index.html
Last active February 1, 2017 12:26
Basic Treant-js example
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8"/>
<title></title>
<!-- stylesheets -->
<link rel="stylesheet" href="https://rawgit.com/lvlds/treant-js/master/Treant.css" type="text/css"/>
</head>
@kavichu
kavichu / index.html
Last active February 1, 2017 12:29
Itaipu Dam Organization diagram example
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8"/>
<title></title>
<!-- stylesheets -->
<link rel="stylesheet" href="https://rawgit.com/lvlds/treant-js/master/Treant.css" type="text/css"/>
</head>
@kavichu
kavichu / flatten_array.js
Created April 16, 2017 19:18
ES6 code to flatten array of arbitrarily nested arrays
let arr = [[1,2,[3]],4];
let flatten = (accu, e) => {
if(!Array.isArray(e)){
return [...accu, e];
}else{
return [...accu, ...e.reduce(flatten, [])];
}
}
@kavichu
kavichu / triple_o_summary.md
Created April 17, 2017 23:19
OpenStack Triple O Troubleshooting - Installing openstack-tripleo-ui from rdo-trunk-newton-tested

Running the quickstart script

bash quickstart.sh $VIRTHOST

Get the IP of the undercloud VM

TASK [setup/undercloud : Get undercloud vm ip address] *************************
task path: /home/ansible/.quickstart/tripleo-quickstart/roles/libvirt/setup/undercloud/tasks/main.yml:295
Monday 17 April 2017 18:04:07 +0000 (0:00:02.322) 0:11:31.488 **********