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 / 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 / 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 / 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>
  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({
/*
Copyright (c) 2011 Andrei Mackenzie
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE