Skip to content

Instantly share code, notes, and snippets.

@tbuehlmann
tbuehlmann / user.rb
Last active December 19, 2015 04:28 — forked from 1dolinski/user.rb
# get all users
@users = User.all
# get users from given ids
ids = [2, 1, 3, 4, 5]
@users = User.find(ids)
!!! 5
%html
%head
%meta{:charset => "utf-8"}
%meta{:name => "viewport", :content => "width=device-width, initial-scale=1, maximum-scale=1"}
%title ScheduleMeNow
/ %title= content_for?(:title) ? yield(:title) : "Myapp"
%meta{:content => "", :name => "description"}
%meta{:content => "", :name => "author"}
data = [1000,1000,5,1000,4,12,-3,999,0,1000]
# declare and initialize variables for the two largest
max, max_2 = nil, nil
# compute the two largest
data.each_with_index do |n, index|
case
when index == 0
max = n
import java.util.Scanner;
class NewCar {
// instance variables
double start, end, galls;
// constructor
NewCar(double start) {
this.start = start;
}
import java.util.Scanner;
class Car {
//instance variables
double start, end, galls;
//constructor
Car(double start, double end, double galls) {
this.start = start;
this.end = end;
class HelloObject
{
String greeting;
HelloObject(String st)
{
greeting=st;
}
HelloObject(HelloObject obj)
{
class HelloTestObject {
String st;
HelloTestObject(String st) {
this.st = st;
}
void speak() {
System.out.println(st);
}
@tbuehlmann
tbuehlmann / PrintX.java
Last active December 16, 2015 15:09 — forked from anonymous/PrintX.java
class PrintX {
public void print(String input, int i) {
for(int j=1; j<=i; j++) {
System.out.println(input);
}
}
public static void main(String[] args) {
PrintX p = new PrintX();
p.print("foo", 3);
@tbuehlmann
tbuehlmann / app.rb
Last active December 16, 2015 09:39 — forked from banister/app.rb
class SprocketsMiddleware
attr_reader :app, :prefix, :sprockets
def initialize(app, prefix)
@app = app
@prefix = prefix
@sprockets = Sprockets::Environment.new
yield sprockets if block_given?
end
Write a program that reads a text file that contains groups of integers
that start with the word "next". For each group, the program computes and writes out
the sum of integers in that group. There may be any number of groups. Example data set:
5 89
next
1 1 1 1 1 1
next
next
1 1 1 1 1 1 1 1 1