This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
myList = [] | |
with open('file.txt') as file: | |
for line in file: | |
myList += line.split(' ') | |
for word in myList: | |
if '@' in word: | |
print word |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* this rotates a string: "lohel".rotate(3) is "hello" */ | |
String.prototype.rotate = function(n) { // n is an integer | |
n %= this.length; // if n too large: modulo | |
var cut = n < 0 ? -n : this.length - n; // cutting point | |
return this.substr(cut) + this.substr(0,cut); | |
}; | |
function rot13_creator() { | |
// compose the dictionary | |
var alph = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$.post(form.prop("action"), parms, function(res) { | |
if (res.success) { | |
$(".overlay.hidden").fadeIn().delay(5000).fadeOut(); | |
form.get(0).reset(); | |
} | |
}, "json"); | |
// Change to this --->> | |
$.post(form.prop("action"), parms, function() { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'time' | |
SHIFTS = [ | |
{id: 1, shiftStart: "2014-07-08 09:00:42 -0700", shiftEnd: "2014-07-08 18:00:42 -0700"}, | |
{id: 1, shiftStart: "2014-07-08 06:57:42 -0700", shiftEnd: "2014-07-08 08:57:42 -0700"}, | |
{id: 1, shiftStart: "2014-07-08 01:57:42 -0700", shiftEnd: "2014-07-08 05:57:42 -0700"}, | |
{id: 1, shiftStart: "2014-07-07 06:57:42 -0700", shiftEnd: "2014-07-07 12:57:42 -0700"}, | |
{id: 1, shiftStart: "2014-07-06 05:57:42 -0700", shiftEnd: "2014-07-06 11:57:42 -0700"} | |
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
arr = [20,30,50,40,100,10,45,95,30,10] | |
def low_high(stock_prices) | |
max = 0 | |
stock_prices.each_with_index do |x, index| | |
current_max = 0 | |
stock_prices[index..-1].each do |y| | |
current_max = y - x | |
if current_max > max | |
max = current_max |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def max_slice(arr) | |
arr.size.times do |x| | |
if sum(arr[x..-1]) >= sum(arr) | |
arr.shift | |
end | |
if sum(arr[x..-2]) > sum(arr) | |
arr.pop | |
end | |
end | |
p arr |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ALPHA = %W(0 A B C D E F G H I J K L M N O P Q R S T U V W X Y Z) | |
def read_word(word) | |
word.gsub(/\s+/, '').upcase.split('').map{|l| ALPHA.index(l)}.reduce(:+) | |
end | |
def get_word | |
puts "Enter a word or more for life count.\n(type quit to quit):" | |
word = gets.chomp | |
p read_word(word) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
arr = [-10,-5,6,6,-10,-100] | |
arr2 = [10,-5,6,6,-10,-100] | |
def max_slice(arr) | |
max = 0 | |
biggest_slice = arr[0..1] | |
arr.each_with_index do |x,i| | |
arr.each_with_index do |y,index| | |
if sum(arr[index..i]) > max | |
biggest_slice = arr[index..i] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rails_helper' | |
require 'create/create_find_resident' | |
describe CreateFindResident do | |
let!(:resident) { FactoryGirl.create :resident } | |
let(:resident_data) { | |
{ | |
"DisplayName"=>"Smith, Bob M", | |
"ResidentSys"=>123, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<ul> | |
{% for content in contents %} | |
<li> | |
<div class="post-item"> | |
{% if not simple_list_page %} | |
<div class="post-header"> | |
<h2><a href="{{content.absolute_url}}">{{ content.name }}</a></h2> |
OlderNewer