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 / search-api-redhen-contact-autocomplete.php
Created June 21, 2016 15:40 — forked from wxactly/search-api-redhen-contact-autocomplete.php
Drupal Search API - Simple RedHen contact autocomplete
<?php
/**
* Implements hook_menu().
*/
function MY_MODULE_menu() {
$items['MY_MODULE/redhen/contact/autocomplete'] = array(
'title' => 'Autocomplete for RedHen Contacts',
'page callback' => 'MY_MODULE_contact_autocomplete',
'access callback' => 'redhen_contact_access',
@algotrader-dotcom
algotrader-dotcom / search-api-example.php
Last active June 21, 2016 16:35 — forked from alanmackenzie/search-api-example.php
Drupal Search Api Custom Search Example
<?php
# http://drupal.stackexchange.com/questions/135918/return-other-indexed-fields-using-searchapiqueryindex
# http://www.phponwebsites.com/2015/12/drupal-7-add-custom-fields-to-search-api-solr-index.html
# https://gist.github.com/acquialibrary/572acdbc4004fbfca02b
# http://drupal.stackexchange.com/questions/115878/search-snippet-does-not-appear-in-search-api-search-page
# Remember disable Tokenizer in Filter (This causes a lot of troubles in highlighting keyword)
$server = search_api_server_load('acquia_search_solr_server');
$index = search_api_index_load('node_index');
@algotrader-dotcom
algotrader-dotcom / 17111_troubleshooting_search.php
Created June 20, 2016 11:43
A script to help evaluate search problems, using drush.
drush ev '
$keys = "*:*";
$rows = 5;
$fields = "score,label,id,entity_id,site,bundle,ss_type,tm_title,content"; // * == All fields
$facets = explode(",", "site,hash,bundle,access__all,entity_type,index_id,ss_language,is_status,ss_type");
// Get Solr.
$solr = false;
if (function_exists("apachesolr_get_solr")) {
// apachesolr.module
$solr = apachesolr_get_solr();
@algotrader-dotcom
algotrader-dotcom / Script to Install JAVA 8
Last active June 20, 2016 03:48 — forked from manishval/gist:28b57a6872b2d5b968a0
Script to Install JAVA 8 (JDK 8u40) on CentOS/RHEL 7/6/5 and Fedora
#!/bin/bash
# Script to Install JAVA 8 (JDK 8u40) on CentOS/RHEL 7/6/5 and Fedora
# http://tecadmin.net/install-java-8-on-centos-rhel-and-fedora/
# Requirements: $yum install wget -y
echo "Installing Java 8 (64bit)"
cd /opt/
wget --no-cookies --no-check-certificate --header "Cookie: gpw_e24=http%3A%2F%2Fwww.oracle.com%2F; oraclelicense=accept-securebackup-cookie" "http://download.oracle.com/otn-pub/java/jdk/8u40-b25/jdk-8u40-linux-x64.tar.gz"
@algotrader-dotcom
algotrader-dotcom / AWS CLI cheat sheet
Last active June 17, 2016 16:50
AWS CLI cheat sheet
1. List all ec2 running with output table
$aws ec2 describe-instances --filters "Name=instance-state-name,Values=running" --output table
2. List all ec2 running with output table, with some fields only
$aws ec2 describe-instances --filters "Name=instance-state-name,Values=running" --query 'Reservations[].Instances[].[Placement.AvailabilityZone, State.Name, InstanceId,InstanceType,Platform,Tags.Value,State.Code,Tags.Values]' --output table
-------------------------------------------------------------------------------------------
| DescribeInstances |
+---------------+----------+-------------+-------------+----------+-------+------+--------+
| eu-central-1a| running | i-0afd59b7 | m3.xlarge | None | None | 16 | None |
| eu-central-1a| running | i-dfff5b62 | m4.xlarge | windows | None | 16 | None |
@algotrader-dotcom
algotrader-dotcom / How to get metadata ec2 instance
Created June 17, 2016 16:22
How to get metadata ec2 instance
$ curl http://169.254.169.254/latest/dynamic/instance-identity/document
{
"version" : "2010-08-31",
"architecture" : "x86_64",
"instanceType" : "t1.micro",
...
"region" : "us-west-2",
"availabilityZone" : "us-west-2b",
...
}
@algotrader-dotcom
algotrader-dotcom / Install awscli
Last active June 17, 2016 16:11
Install awscli
1.Install
$pip install --upgrade awscli
2. Configure
$aws configure
AWS Access Key ID: foo
AWS Secret Access Key: bar
...
3. Verify
$aws iam list-users
@algotrader-dotcom
algotrader-dotcom / ansible aws ec2 dynamic inventory
Last active June 17, 2016 15:34
ansible aws ec2 dynamic inventory
0. Requirements
- Ansible latest version
- AWS access key
- SSH key
1. Install ansible
cd /opt
git clone https://github.com/ansible/ansible.git
cd ansible
source ./hacking/env-setup
@algotrader-dotcom
algotrader-dotcom / Setup jenkins + ansible to autdeploy for JAVA, PHP projects
Last active July 13, 2016 07:13
Setup jenkins + ansible to autdeploy for JAVA, PHP projects
# Requirments
Jenkins, Ansible on the same machine
$docker run -p 8080:8080 -p 50000:50000 -v /opt/jenkins:/var/jenkins_home thuannvn/my-jenkins
Dockerfile can be found here https://github.com/thuannvn/docker-jenkins-extended
# Setup for java project (traditional)
GIT: https://github.com/thuannvn/hello-world-java
Open jenkins -> Create new job -> Choose Freestyle -> Choose Git (Source code management) -> Build (Execute shell) with content:
javac HelloWorld.java
java HelloWorld
@algotrader-dotcom
algotrader-dotcom / server.conf
Created June 14, 2016 07:37 — forked from laurenorsini/server.conf
OpenVPN configuration for /etc/openvpn/server.conf
local 192.168.2.0 # SWAP THIS NUMBER WITH YOUR RASPBERRY PI IP ADDRESS
dev tun
proto udp #Some people prefer to use tcp. Don't change it if you don't know.
port 1194
ca /etc/openvpn/easy-rsa/keys/ca.crt
cert /etc/openvpn/easy-rsa/keys/Server.crt # SWAP WITH YOUR CRT NAME
key /etc/openvpn/easy-rsa/keys/Server.key # SWAP WITH YOUR KEY NAME
dh /etc/openvpn/easy-rsa/keys/dh1024.pem # If you changed to 2048, change that here!
server 10.8.0.0 255.255.255.0
# server and remote endpoints