Skip to content

Instantly share code, notes, and snippets.

View thachp's full-sized avatar

Patrick Thach thachp

View GitHub Profile
#!/bin/bash
CONFIG_FILE="/root/config.txt"
source $CONFIG_FILE
export DISPLAY=:0
export GPU_MAX_ALLOC_PRECENT=100
export GPU_USE_SYNC_OBJECTS=0
export GPU_SINGLE_ALLOC_PERCENT=100
#!/bin/bash
osSeries=none
# OS Series
MODULE_FGLRX=`dpkg -l | grep fglrx | wc -l`
if [ $MODULE_FGLRX -gt 0 ]; then
osSeries=R
fi
MODULE_AMDGPU=`lsmod | grep amdgpu | wc -l`
@thachp
thachp / kadane
Last active August 29, 2015 14:24
Kadane's algorithm in PHP
<?php
/**
* Kadane's algorithm for finding the MAXIMUM contiguous subsequence in a one-dimensional sequence.
* @author thachp
* Attributions:
* http://www.algorithmist.com/index.php/Kadane's_Algorithm
* http://www.turb0js.com/a/Kadane's_algorithm#
*/
@thachp
thachp / quick_sort.php
Last active August 29, 2015 14:23
QuickSort in PHP recursive
<?php
/**
* Quick Sort. It is very practical. The PHP sort() is a quick sort.
* Average Case: O(nlong(n))
* Worst Case: O(n^2) but can be avoided by randomize the pivot.
* @author thachp
*/
/**
@thachp
thachp / splstack.php
Created June 21, 2015 12:04
Splstack .. push and pop.
<?php
/**
* SPLStack provide functionalities of a stack implemented using a doubly linked list.
* Purpose of this is to understand how to implement stack in PHP.
* @author thachp
*/
$stack = new SplStack();
@thachp
thachp / stack.php
Last active August 29, 2015 14:23
Stack implementation using array
<?php
/**
* Implement a stack using array. LIFO. No SPL.
* @author thachp
*/
class Stack {
// dynamic type
private $_stack = array();
@thachp
thachp / add.php
Last active August 29, 2015 14:23
Arithmetic Operations without using the operations
<?php
/**
* Add number without using any arithmetic operators.
* @author thachp *
**/
// add & subject
function add($a, $b) {
if ($b === 0) return $a;
$sum = $a ^ $b; // add
@thachp
thachp / singly.php
Last active August 29, 2015 14:23
Singly Linklist in PHP
<?php
/**
* Singly LinkList in PHP. For fun!
* @author thachp
**/
class Node {
public $data = null;
public $next = null;
@thachp
thachp / menus.xml
Last active August 29, 2015 14:02
Menu Specification for schema.org
<menus>
<menu name="" uid="" currency_symbol="" language="" disabled="">
<menu_description></menu_description>
<menu_note></menu_note>
<menu_duration>
<menu_duration_name></menu_duration_name>
<menu_duration_time_start></menu_duration_time_start>
<menu_duration_time_end></menu_duration_time_end>
</menu_duration>
<menu_groups>
@thachp
thachp / phpunit.xml
Created January 5, 2014 01:22
phpunit.xml
<phpunit bootstrap="bootstrap.php"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false"
syntaxCheck="false"
verbose="true">
</phpunit>