Skip to content

Instantly share code, notes, and snippets.

View avikaco's full-sized avatar

ǟʟʄɨ avikaco

  • Private
  • Jakarta, Indonesia
View GitHub Profile
@avikaco
avikaco / address.html
Last active December 18, 2015 03:39
Address HTML structure
<div itemscope itemtype="http://schema.org/LocalBusiness">
<h2><span itemprop="name">Fine Design</span></h2>
<div itemprop="address" itemscope itemtype="http://schema.org/PostalAddress">
<span itemprop="streetAddress">3102 Highway 98</span>
<span itemprop="addressLocality">Mexico Beach</span>,
<span itemprop="addressRegion">FL</span>
</div>
</div>
@avikaco
avikaco / tel-email.html
Created June 6, 2013 07:05
HTML Tel & Email structure
Tel: <span itemprop="telephone">123-456-7890</span>
Email: <a href="mailto:info@domain.com" itemprop="email">info@domain.com</a>
@avikaco
avikaco / vhost.apacheconf
Last active December 18, 2015 05:29
Apache auto virtual host
<Virtualhost *:80>
VirtualDocumentRoot "/www/dev/%-2+/public"
ServerName vhosts.dev
ServerAlias *.dev
UseCanonicalName Off
LogFormat "%V %h %l %u %t \"%r\" %s %b" vcommon
ErrorLog "/www/dev/vhosts-error_log"
<Directory "/www/dev/*">
Options Indexes FollowSymLinks MultiViews
AllowOverride All
@avikaco
avikaco / humanize.js
Last active December 22, 2015 06:48
Convert camelCase, dashed & underscore to readable text.
function humanize (str, ucword) {
var temp, i;
if (str === null || str === undefined) {
return '';
}
str = str.replace(/([a-z\d])([A-Z]+)/g, '$1 $2').replace(/([_\s]|[-\s])+/g, ' ').trim().toLowerCase();
if(ucword === true) {
<!doctype html>
<html ng-app="Demo">
<head>
<meta charset="utf-8" />
<title>
Using Base Controllers In AngularJS
</title>
</head>
<body ng-controller="demo.SubController">
@avikaco
avikaco / spl_autoloader.php
Created October 18, 2013 10:02
Simple PHP autoloader function
<?php
function autoload($className)
{
$className = ltrim($className, '\\');
$fileName = '';
$namespace = '';
if ($lastNsPos = strrpos($className, '\\')) {
$namespace = substr($className, 0, $lastNsPos);
$className = substr($className, $lastNsPos + 1);
@avikaco
avikaco / route.php
Created October 23, 2013 10:24
Laravel username routing
Route::group(array('prefix' => '{username}', 'before' => 'auth'), function()
{
Route::get('/', 'UserController@profile');
// Route::get('photo', 'PhotoController@index'); // {username}/photo
});
Route::bind('username', function ($value, $route)
{
$user = User::where('username', $value)->first();
@avikaco
avikaco / laravel-get-last-query.php
Created November 16, 2013 15:59
Laravel get last query
function get_last_query() {
$queries = DB::getQueryLog();
$sql = end($queries);
if( ! empty($sql['bindings']))
{
$pdo = DB::getPdo();
foreach($sql['bindings'] as $binding)
{
@avikaco
avikaco / detect-mobile.js
Created December 9, 2013 09:43
Simple code to detect mobile with javascript
var isMobile = {
Android: function() {
return navigator.userAgent.match(/Android/i);
},
BlackBerry: function() {
return navigator.userAgent.match(/BlackBerry/i);
},
iOS: function() {
return navigator.userAgent.match(/iPhone|iPad|iPod/i);
},
<link rel="import" href="../core-scaffold/core-scaffold.html">
<link rel="import" href="../core-header-panel/core-header-panel.html">
<link rel="import" href="../core-menu/core-menu.html">
<link rel="import" href="../core-item/core-item.html">
<link rel="import" href="../core-icon-button/core-icon-button.html">
<link rel="import" href="../core-toolbar/core-toolbar.html">
<link rel="import" href="../core-field/core-field.html">
<link rel="import" href="../core-icon/core-icon.html">
<link rel="import" href="../core-input/core-input.html">
<link rel="import" href="../core-icons/core-icons.html">