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];
## 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 / 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 / ClassDelete.php
Created November 7, 2014 14:27
PHP class delete itself
<?php
class Test
{
public function delete()
{
foreach($GLOBALS as $name => $value) {
if ($GLOBALS[$name] === $this) {
unset($GLOBALS[$name]);
@fijiwebdesign
fijiwebdesign / inotifywait-execute-php.sh
Last active August 29, 2015 14:10
Watch and execute changed PHP files in a directory when they change
#!/bin/bash
#
# inotifywait-execute-php.sh
#
# Example:
# inotifywait-execute-php.sh path/to/project/
#
# Requires: https://github.com/thekid/inotify-win on windows
#
@fijiwebdesign
fijiwebdesign / git-fork-sync-with-original.txt
Last active August 29, 2015 14:13
Git fork a repo and keep updated with original repo
# **fork repo via github UI**
# clone locally
git clone <repo-location>
# add a remote called "upstream" pointing to original repo location
git remote add upstream <repo-location>
# now you have two remotes, "origin" which is the forked repo and "upstream" which is the original
@fijiwebdesign
fijiwebdesign / csv-parsing.php
Created August 4, 2015 14:58
Parsing a CSV file - sorting and aggregating entries
<?php
$filename = './Voters_for_SDC4CRetriever_Official-groupby-email.csv';
$name = null;
$entry_fp = null;
$entry_arr = [];
$fp = fopen($filename, 'r');
while (true) {