Skip to content

Instantly share code, notes, and snippets.

View zabbarob's full-sized avatar

Robert Costa zabbarob

View GitHub Profile
@zabbarob
zabbarob / 7-zip-default-extract.reg
Last active March 1, 2024 08:35
Make 7-Zip extract to folder when double-clicking archives. (based on http://superuser.com/a/447791)
Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\7-Zip.001\shell]
@="extract"
[HKEY_CLASSES_ROOT\7-Zip.001\shell\extract]
@="Extract to Folder"
[HKEY_CLASSES_ROOT\7-Zip.001\shell\extract\command]
@="\"C:\\Program Files\\7-Zip\\7zG.exe\" x \"%1\" -o*"
[HKEY_CLASSES_ROOT\7-Zip.7z\shell]
@zabbarob
zabbarob / anki.css
Created May 7, 2013 22:45
Anki cards, CSS and HTML templates.
@font-face {
font-family: junicode;
src: url('_junicode.ttf');
}
.card, table {
font-family: Helvetica, sans-serif, junicode;
font-size: 20px;
text-align: center;
color: #d03030;
background-color: #fafaf5;
@zabbarob
zabbarob / playnote.js
Created April 26, 2023 23:17
Play Note in Web Browser
// playNote(440, 10) will play a 440 Hz sine wave for 10 seconds
//
// Don't forget that the browser requires some user interaction before
// calling the function, otherwise it will block audio output.
//
// Clicking on the web page once should be enough, though.
//
function playNote(freq, duration = 1) {
const context = new AudioContext();
const oscillator = context.createOscillator();
@zabbarob
zabbarob / load_excel.php
Last active August 23, 2016 23:19
Read an Excel file with Laravel Excel (https://github.com/Maatwebsite/Laravel-Excel)
$sheets = Excel::load($filename)->get();
$firstSheet = $sheets->first();
$header = $firstSheet->first();
$data = $firstSheet->slice(1)->map(function ($row) use ($header) {
return $header->combine($row);
});
@zabbarob
zabbarob / clean-all.sh
Created August 20, 2016 15:17
Clean cached downloads of various package managers on OS X
#!/usr/bin/env bash
# Cleans cached downloads of various package managers on OS X
function myprintf() {
printf "\e[0;35m$1\e[0;m\n"
}
myprintf "Cleaning Homebrew Packages"
brew cleanup
brew cask cleanup
@zabbarob
zabbarob / update-all.sh
Last active August 20, 2016 15:17
Update packages of various package managers on OS X
#!/usr/bin/env bash
# Updates packages of various package managers on macOS
function myprintf() {
printf "\e[0;35m$1\e[0;m\n"
}
myprintf "Updating Homebrew Packages"
brew update
brew upgrade
@zabbarob
zabbarob / MemoryDbTest.php
Last active August 20, 2016 15:07
Use in-memory database when running tests for a Laravel application.
...
use Illuminate\Support\Facades\Artisan;
class MemoryDbTest extends \TestCase
{
public function setUp()
{
parent::setUp();
Artisan::call('migrate');
// optional: Artisan::call('db:seed', ['--class' => 'TestSeeder'])
@zabbarob
zabbarob / echovars.php
Created December 31, 2013 19:04
Web page that prints out the contents of most predefined variables in PHP.
header('Content-Type: text/plain');
function echoAll($a, $n) {
if ($a) {
echo join(PHP_EOL, array_map(function($key) use ($a, $n) {
return $n . "['$key'] = '$a[$key]';";
}, array_keys($a))), PHP_EOL;
}
}
function toWindows1252(string, replacement)
{
var ret = new Array(string.length);
var i, ch;
replacement = typeof replacement === "string" && replacement.length > 0 ? replacement.charCodeAt(0) : 0;
for (i = 0; i < string.length; i++)
{
ch = string.charCodeAt(i);
@zabbarob
zabbarob / which.py
Created September 15, 2013 22:15
check if an executable exist and where it is stored From http://stackoverflow.com/questions/377017/test-if-executable-exists-in-python
def which(program):
import os
def is_exe(fpath):
return os.path.isfile(fpath) and os.access(fpath, os.X_OK)
fpath, fname = os.path.split(program)
if fpath:
if is_exe(program):
return program
else: