Skip to content

Instantly share code, notes, and snippets.

View zoghal's full-sized avatar
🏠
Working from home

Saleh Souzanchi zoghal

🏠
Working from home
View GitHub Profile
@grisha87
grisha87 / purge.php
Last active July 27, 2022 12:16
PHP.Kryptik.AB removal script
<?php
/**
* PHP.Kryptik.AB Cleanup script
*
* Usage: place the script in same directory that contains files / directories
* to be scanned. Then run `php [script_name].php` and wait a bit
*
* @link http://blog.twelvecode.com
* @author Grzegorz Godlewski <[email protected]>
@baghayi-gist
baghayi-gist / gist:4009084
Created November 3, 2012 22:15
PHP: Converting Persian Numbers To English One (function).
function convertPersianNumbersToEnglish($number)
{
$persian = array('۰', '۱', '۲', '۳', '۴', '۵', '۶', '۷', '۸', '۹');
$num = range(0, 9);
return (int)str_replace($persian, $num, $number);
}
@dekart
dekart / nginx.conf
Last active October 12, 2015 09:28
Performance optimizations
timer_resolution 100ms;
worker_priority -5;
events {
use epoll;
worker_connections 2048;
}
server {
ssl_protocols SSLv3 TLSv1 TLSv1.1 TLSv1.2;
@tomdale
tomdale / gist:4004913
Created November 2, 2012 23:10
Per-Type Adapters Proposal

Per-Type Adapter Hooks

Requirements

Many existing JSON APIs are not consistent between types. As JSON endpoints grew organically and were built by different engineers at different times, the style in which records are represented can vary wildly.

Historically, we have asked adapter authors to rely on the fact that the type of record is provided to all adapter hooks (either by passing a type argument, or by passing a record

App.Router.map(function(match) {
match("/posts/:post_id").to("post");
});
App.PostRoute = Ember.Route.extend({
// default implementation
deserialize: function(router, params) {
return App.Post.find(params.post_id);
},
App.PostRoute = Ember.Route.extend({
serialize: function(router, post) {
// what should the state be serialized as
return { post_id: post.get('id') };
},
setupControllers: function(router, post) {
// which content should be used
this.set('controller.content', post);
},
@ghempton
ghempton / ember-analytics.js
Created October 3, 2012 16:00
Drop in addition of analytics to Ember.js applications
Ember.Route.reopen({
enter: function(router) {
this._super(router);
if(this.get('isLeafRoute')) {
var path = this.absoluteRoute(router);
mixpanel.track('page viewed', {'page name' : document.title, 'url' : path});
_gaq.push(['_trackPageview', path]);
}
}
});
@jordanperr
jordanperr / tree_block_helper.js
Created August 28, 2012 03:59
Tree Render, Handlebars
/*** Template Markup
{{#tree my_tree}}
The _id of this node is {{_id}}.
{{/tree}}
***/
/*** Template variable ***/
@Gozala
Gozala / resource.js
Created August 27, 2012 13:42
SDK API for registering new resource URIs
/*jshint asi:true globalstrict:true*/
'use strict';
let { Cc, Ci } = require('chrome')
let ioService = Cc['@mozilla.org/network/io-service;1'].
getService(Ci.nsIIOService)
let resourceHandler = ioService.getProtocolHandler('resource').
QueryInterface(Ci.nsIResProtocolHandler)
// vim: set ft=javascript sw=4 :
window.App = Ember.Application.create({
ApplicationController: Ember.Controller.extend(),
ApplicationView: Ember.View.extend({
templateName: 'application',
click: function(event) {
console.log('appView saw a click');