Skip to content

Instantly share code, notes, and snippets.

View jubstuff's full-sized avatar

Giustino Borzacchiello jubstuff

View GitHub Profile
@jubstuff
jubstuff / autofill.php
Created April 11, 2015 18:22
Wrap text in imagick
<?php
/**
* Auto Fit Text To Image
*
* Write text to image using a target width, height, and starting font size.
*
* @author Clif Griffin
* @url http://cgd.io/2014/auto-fit-text-to-an-image-with-php-and-wordpress
*
@jubstuff
jubstuff / print
Created February 24, 2015 14:47
Print a page in an hidden iframe
<script type="text/javascript">
function closePrint () {
document.body.removeChild(this.__container__);
}
function setPrint () {
this.contentWindow.__container__ = this;
this.contentWindow.onbeforeunload = closePrint;
this.contentWindow.onafterprint = closePrint;
this.contentWindow.focus(); // Required for IE
@jubstuff
jubstuff / queue.rb
Created September 5, 2011 13:41
Stack and Queue in Ruby using array
# queue.rb
#
# Using array as queue
#
# Combine use of push and shift
#
# =OUTPUT=
#
# $ ruby1.9.1 queue.rb
# ["one", "two", "three"]
{"traceEvents":[{"pid":2460,"tid":2490,"ts":121298953076,"ph":"X","cat":"toplevel","name":"ThreadController::Task","dur":4,"tdur":3,"tts":205,"args":{"src_file":"../../base/task/sequence_manager/task_queue_impl.cc","src_func":"PushOntoDelayedIncomingQueue"}},{"pid":2460,"tid":2490,"ts":121298953075,"ph":"X","cat":"disabled-by-default-devtools.timeline","name":"RunTask","dur":22,"tdur":21,"tts":204,"args":{}},{"pid":2460,"tid":2490,"ts":121298953010,"ph":"X","cat":"toplevel","name":"ThreadControllerImpl::RunTask","dur":89,"tdur":86,"tts":142,"args":{}},{"pid":2460,"tid":2490,"ts":121298953101,"ph":"X","cat":"toplevel","name":"ThreadControllerImpl::RunTask","dur":1,"tdur":0,"tts":230,"args":{}},{"pid":2460,"tid":2490,"ts":121299954136,"ph":"X","cat":"toplevel","name":"ThreadController::Task","dur":11,"tdur":11,"tts":265,"args":{"src_file":"../../base/task/thread_pool/delayed_task_manager.cc","src_func":"ScheduleProcessRipeTasksOnServiceThread"}},{"pid":2460,"tid":2490,"ts":121299954135,"ph":"X","cat":"disabled-
@jubstuff
jubstuff / config.yml
Created May 29, 2015 13:59
Create pages in WordPress with Python and Wp-cli
Obj1:
- Obj21
- Obj22
- Obj23
- Obj24
- Obj25
@jubstuff
jubstuff / format_xls_for_YNAB.sh
Created December 27, 2017 14:20
Format ING direct exported XLS to YNAB compliant CSV
#!/bin/bash
if [ $# -eq 0 ]
then
echo "Usage: $0 filename.xls (where the xls is exported from ING direct website)"
exit 1;
fi
result=$(echo $1 | cut -d . -f1);
result+=".csv";
@jubstuff
jubstuff / cycle_button.js
Created January 20, 2016 15:50
A simple button in React that cycles between multiple states
var GiustinoButton = React.createClass({
getInitialState: function() {
return {
current_state: 1,
name: "A"
};
},
stateSwitcher: function() {
switch(this.state.current_state) {
@jubstuff
jubstuff / getTheRemainingArguments.js
Last active January 4, 2016 11:49
How to get all the arguments of a function but the first
function test() {
var otherArgs = Array.prototype.slice.call(arguments, 1);
console.log(otherArgs);
}
console.log('test()');
test();
console.log('test(1)');
test(1);
<!DOCTYPE html>
<html>
<head>
<meta charset=utf-8 />
<title>JS Bin</title>
<style>
#box {
background-color: #369;
height: 100px;
@jubstuff
jubstuff / Vagrantfile
Created January 9, 2014 08:05
Vagrant configuration line to enable symlink creation in Virtualbox shared folders
config.vm.customize ["setextradata", :id, "VBoxInternal2/SharedFoldersEnableSymlinksCreate/SHARE_NAME", "1"]