Skip to content

Instantly share code, notes, and snippets.

View yornaath's full-sized avatar
🔥
buidling

Yornaath yornaath

🔥
buidling
View GitHub Profile
public static function getContentModules() {
$db = Db::getInstance();
$query = "SELECT content_module.content_module_id , " .
" content_module.name, content_module.created_by, " .
" createtime, deletetime, (select count(*) from page p " .
" WHERE p.content_module_id = " .
" content_module.content_module_id AND p.deletetime is null) " .
" as numberOfPages from content_module WHERE deletetime IS NULL";
try {
$stmt = $db->prepare($query);
function Collection (modelname) {
this.modelname = modelname;
this.collection = {}
this.length = 0
}
Collection.prototype.add = function(model) {
this.collection[model[modelname+"Id"]] = model;
this.lenth++
}
var http = require('http'),
cluster = require('cluster')
function hydraServer(requestListener, heads){
var server,
i;
if(cluster.isMaster) {
for(i = 0; i < heads; i++) {
cluster.fork()
}
var Map = (function() {
function Map (name) {
this.init()
this.name = name;
}
Map.prototype.init = function() {
}
SELECT * FROM media
INNER JOIN media_tag
ON media_tag.media_id = media.media_id
INNER JOIN tag
ON tag.tag_id = media_tag.tag_id
WHERE tag.name IN ('tag1','tag2', 'tag3')
jQuery.fn.httpReq = function(opts) {
var oriErrorHandler = opts.error
function errorHandler (argument) {
//gjør standrd ting her
oriErrorHandler()
}
opts['error'] = errorHandler
<?php
public function __get($name, $value) {
if ($name == "tariff" && get_called_class() != get_class($this)) {
return (intval($this->$name) / 100);
} else if ($name == "durationType" && get_called_class() != get_class($this)) {
} else {
return $this->$name;
}
}
var needle = "search for this"
var haystack = "search in this string"
var regexp = new RegExp("(\.*)("+needle+")(\.*)")
regexp.exec(haystack) // === null || [matches]
haystack.match(regexp) // === null || [matches]
@yornaath
yornaath / gist:2881718
Created June 6, 2012 13:04 — forked from lucasfais/gist:1207002
Sublime Text 2 - Useful Shortcuts

Sublime Text 2 – Useful Shortcuts (Mac OS X)

General

⌘T go to file
⌘⌃P go to project
⌘R go to methods
⌃G go to line
⌘KB toggle side bar
⌘⇧P command prompt
@yornaath
yornaath / gist:2881720
Created June 6, 2012 13:04 — forked from lucasfais/gist:1207002
Sublime Text 2 - Useful Shortcuts

Sublime Text 2 – Useful Shortcuts (Mac OS X)

General

⌘T go to file
⌘⌃P go to project
⌘R go to methods
⌃G go to line
⌘KB toggle side bar
⌘⇧P command prompt