Skip to content

Instantly share code, notes, and snippets.

<?php
// ORM request
$v = ORM::factory('user')->where('activated', '=', 1);
// Checks the number of results
$x = clone $v;
var_dump($x->count_all());
// Operations that would change the number of results
<?php
// Data to send
$res = array('success' => TRUE);
// Disable auto_render
$this->auto_render = FALSE;
// Return JSON
$this->response
<?php
Route::set('project_add', 'project/add/<section>',
array(
'section' => '(link)',
))
->defaults(array(
'controller' => 'project',
'action' => 'add_{$section}',
));
@Menencia
Menencia / Kohana.sublime-completions
Created November 23, 2012 11:03
Kohana completions for Sublime Text 2
{
"scope": "source.php - variable.other.php",
"completions":
[
{ "trigger": "HTML::anchor", "contents": "HTML::anchor(${1:uri}, ${2:title = NULL}, ${3:attributes = NULL}, ${4:protocol = NULL})" },
{ "trigger": "HTML::attributes", "contents": "HTML::attributes(${1:attributes = NULL})" },
{ "trigger": "HTML::chars", "contents": "HTML::chars(${1:value = NULL}, ${2:double_encode = TRUE})" },
{ "trigger": "HTML::email", "contents": "HTML::email(${1:email})" },
{ "trigger": "HTML::entities", "contents": "HTML::entities(${1:value}, ${2:double_encode = TRUE})" },
[
{ "keys": ["super+t"], "command": "show_overlay", "args": {"overlay": "goto", "show_files": true} },
{ "keys": ["super+p"], "command": "show_overlay", "args": {"overlay": "command_palette"} },
{ "keys": ["super+d"], "command": "duplicate_line" },
{ "keys": ["super+shift+d"], "command": "run_macro_file", "args": {"file": "Packages/Default/Delete Line.sublime-macro"} },
{ "keys": ["super+k"], "command": "show_panel", "args": {"panel": "console", "toggle": true} },
{ "keys": ["ctrl+shift+c"], "command": "show_original_part" },
{ "keys": ["ctrl+shift+r"], "command": "replace_modified_part" },
{ "keys": ["ctrl+shift+d"], "command": "show_diff" },
// Generated by CoffeeScript 1.3.3
/*
SERVER
*/
var app, cookie, db, express, fs, io, port, server;
port = 3000;
fs = require('fs');
###
SERVER
###
port = 3000
fs = require('fs')
express = require('express')
cookie = require('express/node_modules/cookie')
app = express()
@Menencia
Menencia / gist:4594742
Last active December 11, 2015 11:38
nodejs server chat
#server
logins = []
io.sockets.on 'connection', (client) ->
client.on 'join', (data) ->
# checks if data.login account exists
db.users.findOne {login: data.login}, (err, user) ->
# user found
@Menencia
Menencia / readme.md
Last active March 8, 2022 18:29
Script to update a git project

Update a git repo

With this script, you can easily update a git repo.

Install

curl -# https://gist.githubusercontent.com/Menencia/6435756/raw/update.sh > update.sh
curl -# https://gist.githubusercontent.com/Menencia/6435756/raw/version.sh > version.sh
@Menencia
Menencia / gist:7530820
Last active December 28, 2015 16:39
Returns an array of x random elements with the sum of X
// Returns an array of x random elements with the sum of X
function randomArray(X, max) {
var last = -1, res = [];
while (X > 0 && res.length < max) {
var x = Math.ceil(Math.random()*X);
res.push(x);
X -= x;
last += 1;
}
if (X > 0) {