Skip to content

Instantly share code, notes, and snippets.

View ahgood's full-sized avatar

Guojun ahgood

  • Fullstack Developer
  • Halifax
View GitHub Profile
@rafaelrinaldi
rafaelrinaldi / filterArray.as
Created June 25, 2009 14:33
Search something inside an array, using filters similars to "LIKE" filters from Oracle.
package rinaldi.array
{
import rinaldi.string.isInString;
/**
*
* Search something inside an array, using filters similars to "LIKE" filters from Oracle.
* The search is case sensitive!
*
* @param p_arr Data provider.
@bpedro
bpedro / mkdir_p.js
Last active October 31, 2020 00:35
nodejs implementation of recursive directory creation (https://brunopedro.com/2010/12/15/recursive-directory-nodejs/)
var fs = require('fs');
/**
* Offers functionality similar to mkdir -p
*
* Asynchronous operation. No arguments other than a possible exception
* are given to the completion callback.
*/
function mkdir_p(path, mode, callback, position) {
mode = mode || 0777;
@mikesmullin
mikesmullin / msmtp.sh
Last active March 4, 2021 21:12
install msmtp gmail, a localhost sendmail alternative
# setup msmtp for sending out email
# as an alternative to sendmail
# i prefer this because it is easier to install and configure than sendmail
# especially when using Gmail smtp servers
sudo -i
apt-get install msmtp
ln -s /usr/bin/msmtp /usr/sbin/sendmail
touch /var/log/msmtprc && chmod 666 /var/log/msmtprc
vim /etc/msmtprc
# config options: http://msmtp.sourceforge.net/doc/msmtp.html#A-user-configuration-file
@eligrey
eligrey / html-domparser.js
Last active April 11, 2024 10:34
DOMParser HTML extension - Now a polyfill since HTML parsing was added to the DOMParser specification
/*
* DOMParser HTML extension
* 2019-11-13
*
* By Eli Grey, http://eligrey.com
* Public domain.
* NO WARRANTY EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK.
*/
/*! @source https://gist.github.com/1129031 */
@ScottPhillips
ScottPhillips / .htaccess
Created February 2, 2012 04:30
Common .htaccess Redirects
#301 Redirects for .htaccess
#Redirect a single page:
Redirect 301 /pagename.php http://www.domain.com/pagename.html
#Redirect an entire site:
Redirect 301 / http://www.domain.com/
#Redirect an entire site to a sub folder
Redirect 301 / http://www.domain.com/subfolder/
@arosenhagen
arosenhagen / magento-code-snippets.md
Last active April 8, 2024 09:21
[magento] - code snippets

Magento Code Snippets

Download extension manually using mage

./mage config-set preferred_state stable
./mage clear-cache
./mage sync
./mage download community Module_Name
@taterbase
taterbase / upload.php
Created May 13, 2012 15:03
Simple file upload in php
<!DOCTYPE html>
<html>
<head>
<title>Upload your files</title>
</head>
<body>
<form enctype="multipart/form-data" action="upload.php" method="POST">
<p>Upload your file</p>
<input type="file" name="uploaded_file"></input><br />
<input type="submit" value="Upload"></input>
@ScottPhillips
ScottPhillips / simple-php-crawler.php
Created June 30, 2012 23:41
Simple PHP Crawleer
<?php
function crawl_page($url, $depth = 5)
{
static $seen = array();
if (isset($seen[$url]) || $depth === 0) {
return;
}
$seen[$url] = true;
@feedmeastraycat
feedmeastraycat / get_post_id_by_meta_key_and_value.php
Created July 7, 2012 11:32
WordPress: Get post id by meta key and value
<?php
if (!function_exists('get_post_id_by_meta_key_and_value')) {
/**
* Get post id from meta key and value
* @param string $key
* @param mixed $value
* @return int|bool
* @author David M&aring;rtensson <david.martensson@gmail.com>
*/
function get_post_id_by_meta_key_and_value($key, $value) {
@iwek
iwek / find-in-json.js
Created October 20, 2012 21:43
Searching through JSON
//return an array of objects according to key, value, or key and value matching
function getObjects(obj, key, val) {
var objects = [];
for (var i in obj) {
if (!obj.hasOwnProperty(i)) continue;
if (typeof obj[i] == 'object') {
objects = objects.concat(getObjects(obj[i], key, val));
} else
//if key matches and value matches or if key matches and value is not passed (eliminating the case where key matches but passed value does not)
if (i == key && obj[i] == val || i == key && val == '') { //