Skip to content

Instantly share code, notes, and snippets.

View pixeloution's full-sized avatar

Erik Wurzer pixeloution

  • Apple
  • Austin, TX
View GitHub Profile
@pixeloution
pixeloution / shuffle.js
Created August 13, 2018 15:01
Fisher-Yates Shuffle
function shuffle(a) {
var j, x, i;
for (i = a.length - 1; i > 0; i--) {
j = Math.floor(Math.random() * (i + 1));
x = a[i];
a[i] = a[j];
a[j] = x;
}
return a;
}

this is ** bold ** text

@pixeloution
pixeloution / max.php
Last active August 29, 2015 14:05
Max Memory Usage, PHP
<?php
$unit = ['b','kb','mb','gb','tb','pb'];
$size = memory_get_peak_usage(true);
$usage = @round($size/pow(1024,($i=floor(log($size,1024)))),2).' '.$unit[$i];
echo $usage . PHP_EOL;
1. Why do we refactor?
- We refactor to both clean up our code and make it more readable, as well as making it more modular.
2. What's the difference between "refactoring" and "changing shit"?
- Refactoring has a specific goal.
3. What role do patterns play in refactoring?
- There are certain observable patterns that can clue us in to places that may need refactoring.
4. Why do some refactoring patterns seem to be opposites?
- Because there are different patterns and refactoring methods for different situations.
5. Does refactoring always make code better?
- As long as it is done in a predictable and consistent manner.
ul {
margin : 0;
padding : 0;
list-style-type : none;
}
li {
background : rgba(40,255,91,.15);
}
.columns {
-webkit-column-count : 3;
<?php
public function encrypt( $plaintext )
{
$iv = mcrypt_create_iv( $this->iv_size, MCRYPT_RAND );
$encrypted = mcrypt_encrypt( MCRYPT_RIJNDAEL_128, $this->key, $plaintext, MCRYPT_MODE_CBC, $iv );
return base64_encode( $iv . $encrypted );
}
@pixeloution
pixeloution / gist:7492418
Created November 15, 2013 22:03
some other settings
"font_face": "TheSansMono",
"font_size": 14,
"ignored_packages":
[
"Vintage"
],
"line_padding_bottom": 2,
"line_padding_top": 2,
"soda_classic_tabs": true,
"soda_folder_icons": true,

Multiple SSH Keys settings for different github account

create different public key

create different ssh key according the article Mac Set-Up Git

$ ssh-keygen -t rsa -C "your_email@youremail.com"
@pixeloution
pixeloution / new-user.sql
Created June 28, 2013 17:00
Add a new admin user to wordpress via mySQL
--
-- these are the only values you need to set
-- and then just run these in squence from the mysql terminal
--
SET @USER := 'Your User Name';
SET @EMAIL := 'your@email.com';
SET @PASS := 'your-password-here';
--
-- wordpress will 'upgrade' the MD5 on your first login
-- This SQL implements the Double Metaphone algorythm (c) 1998, 1999 by Lawrence Philips
-- it was translated to Python, and then to SQL from the C source written by Kevin Atkinson (http://aspell.net/metaphone/)
-- By Andrew Collins - Feb, 2007 who claims no rights to this work
-- http://www.atomodo.com/code/double-metaphone/metaphone.sql/view
-- Tested with MySQL 5.1 on Ubuntu 6.01 and Ubuntu 10.4
-- Updated Nov 27, 2007 to fix a bug in the 'CC' section
-- Updated Jun 01, 2010 to fix a bug in the 'Z' section - thanks Nils Johnsson!
-- Updated Jun 25, 2010 to fix 16 signifigant bugs - thanks again Nils Johnsson for a spectacular
-- bug squashing effort. There were many cases where this function wouldn't give the same output
-- as the original C source that were fixed by his careful attention and excellent communication.