Skip to content

Instantly share code, notes, and snippets.

@panicbus
panicbus / reverse.js
Created April 6, 2014 17:28
2 ways to reverse a string in JavaScript
function reverse(str){
letters = "";
for (var i = str.length-1; i >= 0; i--){
letters += str[i];
}
return letters;
}
reverse("nico")
@panicbus
panicbus / easy_js_functions.js
Created April 1, 2014 02:43
5 simple JavaScript functions that do things
//FINDS THE LONGEST WORD IN A STRING
function longestWord(str){
parts = str.split(" ");
longest = 0;
word = 0;
for (var i=0; i < parts.length; i++){
if (longest < parts[i].length) {
longest = parts[i].length;
word = parts[i];
}
@panicbus
panicbus / An-Anonymous-Pen.markdown
Created March 7, 2014 00:34
A Pen by Anonasaurus Rex.

Javascript/JQuery workout

Exercises for fun

ex_1.js

Using only js

###The TreasureHunter

This app is a multi player game where users can register for Treasure Hunts that will allow them to search around their city for "Treasures" based on Clues given to them from a Hunt Master.

App will be used by Hunters on mobile phones and by the Hunt Master on desktop.

A Treasure is searched for based on one Clue revealed at:

  • the start of the game
  • after each consecutive Treasure is found.
SUGGESTION 1:
--------------------------
Consider combining Location into Airport model ie:
Insead of
Location.lat
Location.long
Location.id
@panicbus
panicbus / gist:7202522
Last active December 26, 2015 19:39
Refactoring suggestions for mkyriacou's Devnet app
In show.html.erb views, there is inline css for bold and italic that can be refactored onto a css file.
Tables in views files should be rethought, or a least organized better in the file.
# There are 4 basic steps to implementing your ActionMailer functionality in a Rails app:
# Step 1. Create your ActionMailer object. Remember that it can have any name, but should finish with "Mailer":
rails g mailer UserMailer
class UserMailer < ActionMailer::Base
default from: "fred@fred.com"
def confirm_user(user)
@user = user
@panicbus
panicbus / index.md
Created October 22, 2013 04:03 — forked from rstacruz/index.md

Rails Models

Generating models

$ rails g model User

Associations

belongs_to

has_one

@panicbus
panicbus / gist:6930528
Created October 11, 2013 06:45
Book report number 2

'You throw yourself off a cliff and you assemble an airplane on the way down.'

This is a quote from LinkedIn founded Reid Hoffman in an article called Fail to Succeed in the UK edition of Wired, which gives a series of examples of how failing, or the threat of failure, has produced some of the most successful entrepreneurial endeavors of this century.

The analogy of throwing yourself off a cliff really hits home for me. Even when the stakes aren’t exactly gigantic, no other activity can generate a greater yield of learning moments than risk taking, no matter what size they may be. It gives you an ability to adapt quickly, allows for a heightened awareness of danger, and perspective on what stagnation can do to your overall sense of well-being. It also gives you an opportunity to control your own destiny. Which is a huge factor in achieving goals. I think it’s important to live a life that involves a lot of time spent outsi