Skip to content

Instantly share code, notes, and snippets.

View Narven's full-sized avatar
👾
Walking to the fridge...

P Ξ D R O L U Z Narven

👾
Walking to the fridge...
View GitHub Profile
// ==========================================================================
// Project: Schelp - mainPage
// Copyright: ©2009 My Company, Inc.
// ==========================================================================
/*globals Schelp */
Schelp.mainPage = SC.Page.design({
mainPane: SC.MainPane.design({
childViews: 'middleView topView bottomView'.w(),
@Narven
Narven / sublime_text_preferences
Last active December 11, 2015 13:28
My Sublime Text Preferences
{
"auto_complete_delay": 50,
"auto_complete_selector": "source, text",
"auto_complete_size_limit": 4194304,
"auto_complete_with_fields": true,
"bold_folder_labels": true,
"caret_style": "phase",
"drag_text": false,
"draw_indent_guides": true,
"draw_white_space": "all",
@Narven
Narven / nrvhelper
Created January 25, 2013 10:46
nrvhelper is a css helper that i use for fast prototyping
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
/**
* CSS HELPERS
*
* Copyright (c) <2010> narvenblog.com
*
*
* @author Pedro Luz <narvenblog@gmail.com>
* @copyright 2007-2012 http://narvenblog.com
@Narven
Narven / gzip_mysql_table
Created February 5, 2013 21:51
gzip's a mysql table directly
mysql --host={DB host} --user={user} --password={password} --quick -e {sql} | sed \'s/\t/","/g;s/^/"/;s/$/"/\' | gzip -9 -c > {file}
@Narven
Narven / CDbCriteria_Like_Conditions
Last active December 16, 2015 09:59 — forked from jamband/sample.php
CDbCriteria Examples
<?php
/* SELECT * FROM `hoge` `t`
---------------------------------------------------*/
$c1 = new CDbCriteria();
$m1 = Hoge::model()->findAll($c1);
/* SELECT * FROM `hoge` `t`
----------------------------------------------------*/
<?php
// first approach
...
$criteria = new CDbCriteria;
$criteria->compare("price", 1);
$posts = Post::model()->find($criteria);
...
// second approach
...
@Narven
Narven / jquery_autocomplete_codeigniter
Created April 24, 2013 10:51
jquery ui autocomplete / codeigniter
//needs jquery and jquery-ui
// auto complete
$( "#autocomplete-cities" ).autocomplete({
source: function(request, response) {
//console.info(request, 'request');
//console.info(response, 'response');
$.ajax({
//q: request.term,
<?php
/**
* Sort an array based on a given field key
*
* @param unknown_type $named_recs
* @param unknown_type $order_by
* @param unknown_type $rev
* @param unknown_type $flags
* @return unknown
*/
@Narven
Narven / first_key_of_array
Created May 1, 2013 14:06
If you get from a result of something an array... and might not come always with 0 as the first key, like array[0]... or array[20] u can use this snippet to get always the first key.
reset($array);
$first_key = key($array);
var_dump($array[$first_key]));
@Narven
Narven / search_array_for_key_value
Created May 1, 2013 14:09
Search in a multidimensional array for a specific array with a specific key/pair
// get highlight photo
$search = array_filter($user_photos, function($v) {
if ($v['highlight'] == 1) return $v;
});