Skip to content

Instantly share code, notes, and snippets.

View monaye's full-sized avatar

Monaye Win monaye

View GitHub Profile
@monaye
monaye / Yii-TimeStamp
Created August 17, 2012 12:19
Yii :: Adding Create date and Update Time Automatically
/**
* @return array validation rules for model attributes.
*/
public function rules()
{
return array(
array('title','length','max'=>255),
array('title, created, modified', 'required'),
array('modified','default',
'value'=>new CDbExpression('NOW()'),
@monaye
monaye / gist:3933970
Created October 22, 2012 20:32
Show Home Link in Wordprss 3 menu
function home_page_menu_args( $args ) {
$args['show_home'] = true;
return $args;
}
add_filter( 'wp_page_menu_args', 'home_page_menu_args' );
@monaye
monaye / gist:712354c724e792be3a56
Last active March 25, 2019 05:20
Update Wordpress URL in Mysql
UPDATE wp_options SET option_value = replace(option_value, 'http://www.old-domain.com', 'http://www.new-domain.com') WHERE option_name = 'home' OR option_name = 'siteurl';
UPDATE wp_posts SET guid = replace(guid, 'http://www.old-domain.com', 'http://www.new-domain.com');
UPDATE wp_posts SET post_content = replace(post_content, 'http://www.old-domain.com', 'http://www.new-domain.com');
UPDATE wp_postmeta SET meta_value = replace(meta_value,'http://www.old-domain.com','http://www.new-domain.com');
@monaye
monaye / gist:5641807
Last active December 17, 2015 16:49
CS-Cart: $order_info at checkout
Array (
[order_id] => 300080
[is_parent_order] => N
[parent_order_id] => 0
[company_id] => 0
[user_id] => 14
[total] => 72.00
[subtotal] => 72
[discount] => 0.00
[subtotal_discount] => 0.00
@monaye
monaye / Default.sublime-theme
Last active September 7, 2015 11:00 — forked from anonymous/Default.sublime-theme
Sublime Text 2 Default theme file
[
{
"class": "label_control",
"color": [255, 255, 255],
"shadow_color": [24, 24, 24],
"shadow_offset": [0, -1]
},
{
"class": "button_control",
"content_margin": [6, 5, 6, 6],
@monaye
monaye / Laravel Codeship Deployment Script
Last active April 19, 2020 00:05
Codeship deployment script setup for Laravel 5.1
# Set php version through phpenv. 5.3, 5.4, 5.5, 5.6, 7.0 and 7.1 available
phpenv local 7.1
sed -i'' 's/^memory_limit=.*/memory_limit = 512m/g' ${HOME}/.phpenv/versions/7.1/etc/php.ini
# Install mailhog
brew install mailhog
#Setup MySql
mysql -e 'create database forge;'
mysql -e 'CREATE USER 'forge'@'localhost';'
mysql -e 'GRANT ALL PRIVILEGES ON * . * TO 'forge'@'localhost';'
# Install dependencies through Composer
var doc = context.document
var selectLayersOfType_inContainer = function(layerType, containerLayer) {
// Filter layers using NSPredicate
var scope = (typeof containerLayer !== 'undefined') ? [containerLayer children] : [[doc currentPage] children],
predicate = NSPredicate.predicateWithFormat("(className == %@)", layerType),
layers = [scope filteredArrayUsingPredicate:predicate];
// Deselect current selection
@monaye
monaye / .htaccess
Created February 26, 2018 03:04
Common .htaccess Redirects
#301 Redirects for .htaccess
#Redirect a single page:
Redirect 301 /pagename.php http://www.domain.com/pagename.html
#Redirect an entire site:
Redirect 301 / http://www.domain.com/
#Redirect an entire site to a sub folder
Redirect 301 / http://www.domain.com/subfolder/
@monaye
monaye / update.sql
Created April 12, 2018 03:04
Update column value based on same table's row of other column value
UPDATE
tableA
SET
columnA = SUB.columnB
FROM
( select id, columnB FROM tableA ) as SUB
WHERE
tableA.id = SUB.id;
@monaye
monaye / automatically-set-application-locale.php
Created July 2, 2018 00:38 — forked from paulund/automatically-set-application-locale.php
Automatically Detect Browser Language With PHP
<?php
$supportedLangs = array('en-GB', 'fr', 'de');
$languages = explode(',',$_SERVER['HTTP_ACCEPT_LANGUAGE']);
foreach($languages as $lang)
{
if(in_array($lang, $supportedLangs))
{