Skip to content

Instantly share code, notes, and snippets.

View fijiwebdesign's full-sized avatar

Gabirieli Lalasava fijiwebdesign

View GitHub Profile
@fijiwebdesign
fijiwebdesign / shell.php
Created August 23, 2014 13:49
PHP shell interpreter. Just copy to a file and execute the file to drop into a PHP command line.
#!/usr/bin/env php
<?php while (1) { fputs(STDOUT, "\n\-PHP$ "); eval(trim(fgets(STDIN))); } ?>
@fijiwebdesign
fijiwebdesign / single-page-scroll.js
Last active August 29, 2015 14:06
Make all in page anchors scroll page with animation
// requires jquery selector
$("a[href^=#]").click(function(e) {
var duration = $(this).data('scroll') || 750;
var target = $(this).attr('href');
var $el = $(target);
if ($el.length || target == '#') {
e.preventDefault(); // prevent jumping to target or adding hash in url
// scroll to the element
$('html, body').animate({
scrollTop: target == '#' ? 0 : $el.offset().top
@fijiwebdesign
fijiwebdesign / apache2 dump modules
Created October 4, 2014 09:43
Show list of apache modules
apache2ctl -t -D DUMP_MODULES
@fijiwebdesign
fijiwebdesign / detect-font.jquery.js
Last active August 29, 2015 14:07
Detect font-family of element in jquery
/**
* Detects the font of an element from the font-family css attribute by comparing the font widths on the element
* @link http://stackoverflow.com/questions/15664759/jquery-how-to-get-assigned-font-to-element
*/
(function($) {
$.fn.detectFont = function() {
var fontfamily = $(this).css('font-family');
var fonts = fontfamily.split(',');
if ( fonts.length == 1 )
return fonts[0];
@fijiwebdesign
fijiwebdesign / detect-available-fonts.js
Last active February 24, 2024 15:04
Detect available fonts with JS
/**
* JavaScript code to detect available availability of a
* particular font in a browser using JavaScript and CSS.
*
* Author : Lalit Patel
* Website: http://www.lalit.org/lab/javascript-css-font-detect/
* License: Apache Software License 2.0
* http://www.apache.org/licenses/LICENSE-2.0
* Version: 0.15 (21 Sep 2009)
* Changed comparision font to default from sans-default-default,
## Atom Cheatsheet.
#### Project Key Bindings.
- 'cmd-shift-p': open the command palette.
- 'cmd-p' or 'cmd-t': open the fuzzy finder to find a file.
- 'cmd-b': look for a file that is already open.
- 'cmd-shift-b': search the list of files modified and untracked in your project repository.
- 'ctrl-0': open and focus the the tree view.
- 'cmd-shift-f': find and replace in the entire project.
@fijiwebdesign
fijiwebdesign / inotifywait-cmd.sh
Last active May 28, 2016 04:36
Inotifywait watch files and run command
#!/bin/bash
# inotifywait-cmd.sh
#
# Example:
# inotifywait-cmd.sh test/ 'phpunit --verbose test/ModelReferencesTest.php'
#
# Requires: https://github.com/thekid/inotify-win on windows
#
# author: Gabe LG <gabe@fijiwebdesign.com>
@fijiwebdesign
fijiwebdesign / get_obj_id.php
Last active August 29, 2015 14:08
Retrieve human readable unique object Ids
<?php
/**
* @param Object $obj The Object to create an Id for
* @return String A human readable unique ID for the Object
*
* @internal Requires PHP5.2.0
* @see http://php.net/manual/en/function.spl-object-hash.php
*/
function get_obj_id($obj)
@fijiwebdesign
fijiwebdesign / IsAssociativeArrayBench.php
Created November 1, 2014 19:45
Is Associative Array or Indexed Array Benchmarks.
<?php
// usage
if(!isset($argv[1])){
echo "\nUsage: ".$argv[0]." [options] iterations
Required:
iterations - Number of iterations of each test
Example:
@fijiwebdesign
fijiwebdesign / fix-subtitle-times.php
Created November 1, 2014 20:45
Fix the times for each subtitle in a srt subtitle file
<?php
/**
* Adds the given seconds to the subtitle file
* @author gabe@fijiwebdesign.com
*/
if ($argc < 2) {
echo "Usage: $argv[0] filename seconds [speed]
filename - name of subtitle file to read
seconds - amount of seconds to add to the times. If subtracting use negative values. eg: \"-5\"