Skip to content

Instantly share code, notes, and snippets.

/**
* Connects to Apple Push Notification service server.
*
* @throws ApnsPHP_Exception if is unable to connect.
* @return @type boolean True if successful connected.
*/
protected function _connect()
{
$sURL = $this->_aServiceURLs[$this->_nEnvironment];
unset($aURLs);
@cherifya
cherifya / FastCGI
Created November 29, 2012 13:59
FastCGI
#!/bin/bash
BIND=127.0.0.1:9000
USER=www-data
PHP_FCGI_CHILDREN=15
PHP_FCGI_MAX_REQUESTS=1000
PHP_CGI=/usr/bin/php-cgi
PHP_CGI_NAME=`basename $PHP_CGI`
PHP_CGI_ARGS="- USER=$USER PATH=/usr/bin PHP_FCGI_CHILDREN=$PHP_FCGI_CHILDREN PHP_FCGI_MAX_REQUESTS=$PHP_FCGI_MAX_REQUESTS $PHP_CGI -b $BIND"
RETVAL=0
@cherifya
cherifya / worpress
Created November 29, 2012 14:04
Wordpress site config for nginx
server{
listen 80; #or change this to your public IP address eg 1.1.1.1:80
server_name wordpress; #change this to the domain name, for example www.myblog.com
access_log /var/log/wordpress.access_log;
error_log /var/log/wordpress.error_log;
location / {
root /home/your-user-name/Sites/wordpress;
index index.php index.html index.htm;
@cherifya
cherifya / 1line-notepad
Last active December 12, 2015 01:38
One line notepad in browser with Save button for saving the snippet. Copy and paste the line in your browser's address bar. And voila!
data:text/html;charset=utf-8, <title>TextEditor</title><body contenteditable style="font-size:1.5rem;font-family:'Monaco', sans-serif;line-height:1.4;max-width:70rem;margin:0 auto;padding:3rem;background-color:rgb(233,233,225);color:rgb(68,68,68);" spellcheck="false"> <textarea id="txtBody" style="font-size: 1.5em; width: 100%; height: 90%; font-family: inherit;" autofocus> </textarea> <button onClick="SaveTextArea()" style="margin-top: 20px; font-size: 1.1em;">Save</button> <script language="javascript" type="text/javascript"> function SaveTextArea() { window.location = "data:application/octet-stream," + escape(txtBody.value); } </script> </body>
@cherifya
cherifya / UIImageView+Webcache_Animation.c
Last active December 27, 2016 07:10
Improve SDWebImage library with support for a UIActivityIndicator and optional image transition. The transition animation is a simple fade-in.
//
// UIImageView+Webcache_Animation.m
// Tubesmix
//
// Created by Cherif YAYA on 17/03/13.
// Copyright (c) 2013 Cherif YAYA. All rights reserved.
//
#import "UIImageView+Webcache_Animation.h"
  1. Install globally npm install -g profiler
  2. Start your process with node --prof this will create a v8.log file
  3. Build nprof by running /Users/balupton/.nvm/v0.8.12/lib/node_modules/profiler/tools/build-nprof
  4. Run /Users/balupton/.nvm/v0.8.12/lib/node_modules/profiler/nprof this will read the v8.log profile and give you nice ouput
  1. Install globally npm install -g profiler
  2. Start your process with node --prof this will create a v8.log file
  3. Run /usr/local/lib/node_modules/profiler/build/Release/nprof v8.log this will read the v8.log profile and give you nice ouput
  1. Install to your app npm install nodetime
@cherifya
cherifya / for=()-{}-(faster).snippet
Created April 24, 2013 13:23
Sublime Text 2 Snippets
<snippet>
<content><![CDATA[for (var ${20:i} = 0, ${30:l} = ${1:Things}.length; ${20:i} < ${30:l}; ${20:i}++) {
${100:${1:Things}[${20:i}]}$0
};]]></content>
<tabTrigger>for</tabTrigger>
<scope>source.js</scope>
<description>for (…) {…} (Improved Native For-Loop)</description>
</snippet>
// A (quick and dirty) view which renders its content as a best-fit grid – that is, it shows all items,
// laid out as close to evenly as possible.
// Known issues:
// - doesn't update when content changes (wasn't part of my needs); easy observer fix
// - isn't a subclass of SC.CollectionView
// - someone with the maths could optimize the calculations
// - child views are never destroyed, only created and cached
BestFitGridView = SC.View.extend({
$(function() {
var $sidebar = $("#sidebar"),
$window = $(window),
offset = $sidebar.offset(),
topPadding = 20;
$window.scroll(function() {
if ($window.scrollTop() > offset.top) {
$sidebar.stop().animate({