Skip to content

Instantly share code, notes, and snippets.

View ryanhs's full-sized avatar

ryan hs ryanhs

  • PT Astra Internasional
  • Jakarta
View GitHub Profile
@ryanhs
ryanhs / js
Last active August 29, 2015 14:17
PS auto translate -_-
$('div[name="modules_div"]').each(function(){
id = $(this).attr('id')
$('#' + id + ' table tbody').children().each(function(k, v){
i = 0;
text = '';
$(this).children().each(function(){
if(i == 0){
text = $(this).text()
@ryanhs
ryanhs / cpus
Created March 17, 2015 08:58
multi thread (maybe processor) in c
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
int main() {
long cpu_online = -1;
long cpu_max = -1;
@ryanhs
ryanhs / gist:3e5c85f996e8233285e6
Created April 30, 2015 02:36
wp check version
find . -name 'version.php' -path '*wp-includes/*' -print -exec grep '$wp_version =' {} \; -exec echo '' \;
@ryanhs
ryanhs / ipk.php
Created May 23, 2016 09:21
hitung ipk, PHP
<?php
function A2N($alphabet) {
$alphabet = strtoupper($alphabet);
$result = -(ord($alphabet) - 69);
return $result > 0 && $result <= 4 ? $result : 0;
}
function calculateGPA($grades) {
@ryanhs
ryanhs / mod_xml2enc-installer.sh
Created May 27, 2016 12:56 — forked from oskarnrk/mod_xml2enc-installer.sh
Install mod_xml2enc for Apache2 in Ubuntu 13.10 or later
#!/bin/sh
sudo apt-get install apache2-prefork-dev libxml2 libxml2-dev apache2-dev
mkdir ~/modbuild/ && cd ~/modbuild/
wget http://apache.webthing.com/svn/apache/filters/mod_xml2enc.c
wget http://apache.webthing.com/svn/apache/filters/mod_xml2enc.h
sudo apxs2 -aic -I/usr/include/libxml2 ./mod_xml2enc.c
cd ~
sudo rm -rfd ~/modbuild/
sudo service apache2 restart
<?php
function A2N($alphabet) {
// if alphabet like AB, BA..
if (strlen($alphabet) > 1) {
$result = 0;
foreach (str_split($alphabet) as $chr) {
$result += A2N($chr);
}
return $result / count(str_split($alphabet));
@ryanhs
ryanhs / chess engine evaluation.txt
Created July 21, 2016 16:12
CHESS Engine Categorized
CHESS Engine Categorized
by strong
- Stockfish
- Gull
- Fruit
- GNU Chess
by Comment / Clean Code / didactic
- Crafty
# install openjdk
sudo apt-get install openjdk-7-jdk
# download android sdk
wget http://dl.google.com/android/android-sdk_r24.2-linux.tgz
tar -xvf android-sdk_r24.2-linux.tgz
cd android-sdk-linux/tools
# install all sdk packages
@ryanhs
ryanhs / CORS.php
Last active August 14, 2016 16:36
<?php namespace App\Http\Middleware;
use Closure;
use Illuminate\Contracts\Routing\Middleware;
use Illuminate\Http\Response;
class CORS implements Middleware {
/**
* Handle an incoming request.
@ryanhs
ryanhs / virtualenv-auto.sh
Created May 19, 2017 04:03
execute something when entering directory added on .bashrc
# virtualenv auto activation
function cd {
builtin cd "$@"
DEACTIVATE_TYPE="function";
DEACTIVATE_EXIST=$(type -t deactivate);
if [ -d ".venv" ]
then
source .venv/bin/activate #auto activate
else
if [ "$DEACTIVATE_EXIST" == "$DEACTIVATE_TYPE" ]; then deactivate; fi #auto deactivate