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 / gist:0eca6d520b4040d6b61a
Last active November 22, 2017 00:30
find all in file, test
find . -name '*.php' -print0 | xargs -0 -I file grep -inH "expiration_date =" file
@ryanhs
ryanhs / ucwords.js
Created May 22, 2016 11:27 — forked from rickycheers/ucwords.js
ucwords in JavaScript - Equivalent to PHP's ucwords() Returns a string with the first letter in upper case of each word.
String.prototype.ucwords = function() {
str = this.toLowerCase();
return str.replace(/(^([a-zA-Z\p{M}]))|([ -][a-zA-Z\p{M}])/g,
function(s){
return s.toUpperCase();
});
};
@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