Skip to content

Instantly share code, notes, and snippets.

View todiadiyatmo's full-sized avatar

Todi Adiyatmo Wijoyo todiadiyatmo

View GitHub Profile
$(document).ready(function() {
// create canvas
var canvas = document.createElement("canvas");
canvas.height = 300; // important! because default canvas size is 300x150
var ctx = canvas.getContext('2d');
// create img
var img = document.createElement("img");
// IMPORTANT adding shadow map - each area has different background color
@todiadiyatmo
todiadiyatmo / javascript-object-boilerplate
Created July 15, 2014 09:40
Basic Javascript Object
var Student = (function(){
var _nim;
var _name;
function Student(nim, name){
_nim = nim;
_name = name;
}
Student.prototype.getNim(){
@todiadiyatmo
todiadiyatmo / register_post_type.php
Last active August 29, 2015 14:07
WP Register Post Type
<?php
/*
* REGISTER JOB POSTS TYPE
*/
function jobs_post_type()
{
$config = array(
'label' => __( 'Jobs', 'jobs' ),
'description' => __( 'Jobs', 'jobs' ),
@todiadiyatmo
todiadiyatmo / skill_taxonomy.php
Last active August 29, 2015 14:07
Skill Taxonomy in WordPress
<?php
/*
* Register Skill Taxonomy
*/
function create_skill_taxonomy() {
register_taxonomy(
'skills', // Taxonomy Name
array('job','resume'), // Post Type
array(
@todiadiyatmo
todiadiyatmo / custom_post_type_and_capability.php
Last active July 8, 2019 22:59
WP Custom Post Type and Custom Capability Role
<?php
// Init new Role and add all capability to editor and admin
function custom_post_type_capability_admin()
{
// List the role that we want to give a full access
$roles = array('editor','administrator');
// List of the post type that will have custom capability
@todiadiyatmo
todiadiyatmo / get-all-terms.php
Created October 24, 2014 03:15
Get All Terms WordPress
<?php
$termArgs = array(
'orderby' => 'name',
'hide_empty' => 0
);
$skills = get_terms('skills',$termArgs );
@todiadiyatmo
todiadiyatmo / get-current-user-role.php
Last active August 29, 2015 14:09
Get Current User Role
<?php
global $current_user, $wpdb;
$role = $wpdb->prefix . 'capabilities';
$current_user->role = array_keys($current_user->$role);
$role = $current_user->role[0];
<VirtualHost *:80>
ServerName 7mcity.dev
ServerAlias *.7mcity.dev
DocumentRoot /home/todiadiyatmo/htdocs/7mcity/
RewriteEngine On
<Directory /home/todiadiyatmo/htdocs/7mcity/>
Options Indexes FollowSymLinks
AllowOverride Fileinfo Options All
Order allow,deny
ab -n <num_requests> -c <concurrency> <addr>:<port><path>
@todiadiyatmo
todiadiyatmo / xpath
Last active August 29, 2015 14:14
XPath
// Get class
$x("//h2[@class='postingtile']/text()")
/// get child of a class
$x("//div[@class='post-title']//span")