Skip to content

Instantly share code, notes, and snippets.

@zyphlar
zyphlar / heatsync-area-codes.txt
Created Feb 9, 2014
Area codes in the HeatSync Labs Database
View heatsync-area-codes.txt
(110 results for 480)
(46 results for 602)
Other area/country codes:
+353
088
208
209
240
303
@zyphlar
zyphlar / heatsync-values.md
Last active Aug 29, 2015
Brainstorming core/succinct HeatSync Values (for a potential welcome sign)
View heatsync-values.md
  • you can make anything you want here, even if the tools aren't here yet

  • you are responsible for, and capable of, creating the change you want to see in the world

  • it's okay to mess up, just fix and learn from your mistakes

  • be completely honest with yourself and others

  • we are hands-on, cooperative, and behave excellently to each other

@zyphlar
zyphlar / binary_multiple.rb
Last active Aug 29, 2015
binary multiple
View binary_multiple.rb
# from http://stackoverflow.com/questions/19305067/regex-binary-multiple-of-4
class String
def binary_multiple_4?
(/^[10]*00$/ =~ self) == 0
end
end
puts "4"
puts 4.to_s(2).binary_multiple_4?
@zyphlar
zyphlar / li_link_to.rb
Last active Aug 29, 2015
Helper for generating menu links (inside an <li> tag, with an active class if we're on the current page)
View li_link_to.rb
@zyphlar
zyphlar / business.rb
Last active Aug 29, 2015
Creating a many-to-many via params and accepts_nested_attributes
View business.rb
class Business < ActiveRecord::Base
has_many :businesses_users, :primary_key=>:business_id
has_many :users, through: :businesses_users
end
@zyphlar
zyphlar / countdown.html
Created Feb 22, 2014
HTML/Javascript Countdown timer
View countdown.html
<script type="text/javascript">// <![CDATA[
/* Javascript Countdown Timer
* Will Bradley (www.willbradley.name) Dec. 2009
* Code released publicly without any warranty or license.
*/
function showtime() {
dateString = new Date().toUTCString();
now = Date.parse(dateString);
xmasDateString = new Date(1261724400000).toUTCString(); // The long number is December 25, 2009 in Javascript's .getTime() format. You can put almost any value in here, including plain english dates.
@zyphlar
zyphlar / turtle.rb
Last active Aug 29, 2015
Finding first intersection of a turtle's path (N,E,S,W)
View turtle.rb
def solution(instructions)
position = [0,0]
directions = [
[0,1], # north
[1,0], # east
[0,-1], # south
[-1,0] # west
]
current_dir = 0;
history = []
@zyphlar
zyphlar / symfony-security-filter.php
Last active Aug 29, 2015
Prototype of a Symfony2 PHP securitycontext filter helper
View symfony-security-filter.php
<?php
class SomeController {
private function filterSecurityContext($action, $items){
$user = $this->get('security.context')->getToken()->getUser();
$results = array();
foreach($items as $item){
if($this->get('security.context')->isGranted($action, $item)){
$results[] = $item;
}
@zyphlar
zyphlar / assertionWrapper.phpunit.php
Last active Aug 29, 2015
Wrapper for cleaning up repetitious assertions in PHPunit / Symfony tests
View assertionWrapper.phpunit.php
<?php
namespace Acme\YourCompanyBundle\Tests\Controller;
use Liip\FunctionalTestBundle\Test\WebTestCase;
use Doctrine\ORM\Tools\SchemaTool;
// Note: be sure to replace any instance of "Your"/"your" with the appropriate values.
class YourControllerTest extends WebTestCase
@zyphlar
zyphlar / example.js
Last active Aug 29, 2015
Javascript / JQuery for testing if a given IP is in the IANA reserved range
View example.js
alert( is_iana_reserved_ip("192.168.5.5") );
alert( is_iana_reserved_ip("192.200.5.5") );