Skip to content

Instantly share code, notes, and snippets.

@zyphlar
zyphlar / heatsync-area-codes.txt
Created February 9, 2014 02:30
Area codes in the HeatSync Labs Database
(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 August 29, 2015 13:56
Brainstorming core/succinct HeatSync Values (for a potential welcome sign)
  • 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 August 29, 2015 13:56
binary multiple
# 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 August 29, 2015 13:56
Helper for generating menu links (inside an <li> tag, with an active class if we're on the current page)
@zyphlar
zyphlar / business.rb
Last active August 29, 2015 13:56
Creating a many-to-many via params and accepts_nested_attributes
class Business < ActiveRecord::Base
has_many :businesses_users, :primary_key=>:business_id
has_many :users, through: :businesses_users
end
@zyphlar
zyphlar / countdown.html
Created February 22, 2014 20:33
HTML/Javascript Countdown timer
<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 August 29, 2015 14:00
Finding first intersection of a turtle's path (N,E,S,W)
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 August 29, 2015 14:02
Prototype of a Symfony2 PHP securitycontext filter helper
<?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 August 29, 2015 14:03
Wrapper for cleaning up repetitious assertions in PHPunit / Symfony tests
<?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 August 29, 2015 14:03
Javascript / JQuery for testing if a given IP is in the IANA reserved range
alert( is_iana_reserved_ip("192.168.5.5") );
alert( is_iana_reserved_ip("192.200.5.5") );