Skip to content

Instantly share code, notes, and snippets.

View algotrader-dotcom's full-sized avatar

Mai_Xoa algotrader-dotcom

View GitHub Profile
@algotrader-dotcom
algotrader-dotcom / content_recipe.module
Created November 25, 2015 03:14 — forked from jekamozg/content_recipe.module
Drupal 7 taxonomy term link rewrite
/**
* Implementation of hook_entity_info_alter().
*
* Redirect any links to program taxonomy terms to their corresponding node page.
*/
function content_recipe_entity_info_alter(&$entity_info) {
$entity_info['taxonomy_term']['uri callback'] = 'content_recipe_taxonomy_term_uri';
}
/**
@algotrader-dotcom
algotrader-dotcom / us-state-names-abbrevs.php
Created December 8, 2015 10:31 — forked from maxrice/us-state-names-abbrevs.php
US State Names & Abbreviations as PHP Arrays
<?php
/* From https://www.usps.com/send/official-abbreviations.htm */
$us_state_abbrevs_names = array(
'AL'=>'ALABAMA',
'AK'=>'ALASKA',
'AS'=>'AMERICAN SAMOA',
'AZ'=>'ARIZONA',
'AR'=>'ARKANSAS',
@algotrader-dotcom
algotrader-dotcom / solr-test-query.php
Created December 13, 2015 13:57 — forked from cesarmiquel/solr-test-query.php
Call Apache Solr usings the apachesolr Drupal module and parse the response.
<?php
// -------------------------------------------------------------------------
//
// Taken from:
// http://worldofdrupal.blogspot.com.ar/2014/01/drupal-7-apache-solr-custom-query.html
//
// -------------------------------------------------------------------------
// Search parameters
@algotrader-dotcom
algotrader-dotcom / SolrDrupalCheatSheet.md
Created December 13, 2015 15:30 — forked from mankyKitty/SolrDrupalCheatSheet.md
This is a cheat sheet and rough guide to the integration of Drupal and Apache Solr. It will contain useful functions and how to combine them, a basic layout on how the components fit together, and some DOs and DON'Ts. All of this is based on the [apachesolr](http://drupal.org/project/apachesolr) integration, if you're using a different module th…

#Drupal & Apache Solr Integration

This is a cheat sheet and rough guide to the integration of Drupal and Apache Solr. It will contain useful functions and how to combine them, a basic layout on how the components fit together, and some DOs and DON'Ts. All of this is based on the apachesolr integration, if you're using a different module then this will probably be of no use to you.

Useful Functions

Load All Environments

Within the Apache Solr module there is support for connecting to multiple Solr instances, each the configured connections is considered an environment within the context of the Solr modules operations. When you're interacting with Solr and there is only one connection configured then you mostly do not have to be concerned with this as the module will load the default environment by itself. However you should always try to ensure that anything you construct around Solr is designed to handle the existence of multiple environments.

@algotrader-dotcom
algotrader-dotcom / cleanse.php
Created December 17, 2015 06:36 — forked from gcoop/cleanse.php
Simple cleanse function to remove special chars from a string (amongst other things) in PHP
<?php
function cleanse($string, $allowedTags = array())
{
if (get_magic_quotes_gpc()) {
$string = stripslashes($stringIn);
}
// $string = kses($string, $allowedTags); // For kses {@see http://sourceforge.net/projects/kses/}
// ============
@algotrader-dotcom
algotrader-dotcom / server_querystring.js
Created December 19, 2015 12:27 — forked from johnschimmel/server_querystring.js
NodeJS web server that accepts a querystring variable in the URL and stores the new name in local variable
/************************************************
FILENAME
server_querystring.js
DESCRIPTION
creates a web server that
display "Hello Dynamic World Wide Web"
it includes a web form to accept a new name from the user via the querystring and displays it.
the new name will be stored in a local variable 'defaultName'.
@algotrader-dotcom
algotrader-dotcom / hhvm-exclude-directory.md
Created December 29, 2015 05:02 — forked from tegansnyder/hhvm-exclude-directory.md
Exclude a directory from being processed by HHVM (HHVM Bypass for PHP-FPM)

I was looking for a way to load certain files using regular PHP and mix and match HHVM with PHP-FPM. Here is an example of how to use PHP-FPM to process files in the /exclude/ directory and HHVM for all other files.

## Use regular ol' PHP for files in this directory
location ^~ /exclude/ {
  include fastcgi_params;
  fastcgi_pass  127.0.0.1:9000;
  fastcgi_index index.php;
  fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
  break;
@algotrader-dotcom
algotrader-dotcom / tmux-1.8-on-CentOS-6.x.txt
Created December 29, 2015 09:55 — forked from sturadnidge/tmux-1.8-on-CentOS-6.x.txt
Install tmux 1.8 on CentOS 6.x minimal (64bit)
# download latest libevent2 and tmux sources, and extract them somewhere
# (thx bluejedi for tip on latest tmux URL)
#
# at the time of writing:
# https://github.com/downloads/libevent/libevent/libevent-2.0.21-stable.tar.gz
# http://sourceforge.net/projects/tmux/files/latest/download?source=files
#
# install deps
yum install gcc kernel-devel make ncurses-devel
@algotrader-dotcom
algotrader-dotcom / mac_xwindows_x11_xvfb_headless_firefox_howto.md
Created December 30, 2015 04:30 — forked from textarcana/mac_xwindows_x11_xvfb_headless_firefox_howto.md
Headless Selenium on CentOS 6.3 (Mac XWindows / X11 / Xvfb / Headless Firefox / Selenium howto)

XWindows for Headless Selenium

X Wing art by Paul Harckham

How to set up a Headless Selenium Testing environment for CentOS 6.3.

On your CentOS 6.3 host

Follow these steps to set up a CentOS 6.3 host to run headless Selenium tests with Firefox.

@algotrader-dotcom
algotrader-dotcom / extract_emails_from_text.py
Created January 5, 2016 16:25 — forked from dideler/example.md
A python script for extracting email addresses from text files. You can pass it multiple files. It prints the email addresses to stdout, one address per line. For ease of use, remove the .py extension and place it in your $PATH (e.g. /usr/local/bin/) to run it like a built-in command.
#!/usr/bin/env python
#
# Extracts email addresses from one or more plain text files.
#
# Notes:
# - Does not save to file (pipe the output to a file if you want it saved).
# - Does not check for duplicates (which can easily be done in the terminal).
#
# (c) 2013 Dennis Ideler <ideler.dennis@gmail.com>