Skip to content

Instantly share code, notes, and snippets.

View johncrisostomo's full-sized avatar
🌏
Not much contrib here as my org is now using a ADO exclusively

John Crisostomo johncrisostomo

🌏
Not much contrib here as my org is now using a ADO exclusively
  • JLL Technologies
  • Singapore
View GitHub Profile
@johncrisostomo
johncrisostomo / Age.java
Created June 10, 2011 09:10
lab lecture
import java.io.*;
public class Age {
public static void main(String args[]) throws IOException {
int age;
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
System.out.print("Enter your age : ");
age = Integer.parseInt(br.readLine());
System.out.println("Your age is " + age);
}
@johncrisostomo
johncrisostomo / sieve.rb
Created July 13, 2011 12:57
Sieve of Eratosthenes in Ruby
print "Enter maximum number : "
n = gets.to_i
primes = (2..n).to_a
i = 0
while primes[i]**2 < primes.last
prime = primes[i]
primes = primes.select { |num| num == prime || num % prime != 0 }
@johncrisostomo
johncrisostomo / sieve.rb
Created July 13, 2011 12:56
Sieve of Eratosthenes in Ruby
print "Enter maximum number : "
n = gets.to_i
primes = (2..n).to_a
i = 0
while primes[i]**2 < primes.last
prime = primes[i]
primes = primes.select { |num| num == prime || num % prime != 0 }
@johncrisostomo
johncrisostomo / shortener.py
Created September 13, 2011 18:08
bit.ly shortener cli
#!/usr/bin/env python
# URL SHORTENER CLI v0.01 by 4R5C4R105U5
# CREATED ON SEPT. 14, 2011
# GUI COMING SOON
import urllib
api = "" # I LEFT THIS BLANK ON PURPOSE
login = "" # LEFT BLANK ON PURPOSE AS WELL, USE YOUR OWN LOGIN AND API KEY! :D
user_url = raw_input('Enter url to be shortened : ')
@johncrisostomo
johncrisostomo / lighboxnamalupet.html
Created July 30, 2012 08:40
wala, lightbox lang naman.
<!DOCTYPE html>
<html>
<head>
<title>LIGHTBOX NA MALUPET</title>
<style>
.black_overlay{
display: none;
position: absolute;
top: 0%;
left: 0%;
@johncrisostomo
johncrisostomo / README.md
Created May 7, 2018 01:06
Save files in Meteor

Create a Meteor app and put the client_/server_ files in a client/server directories. Also, create a public dir to save the uploaded files.

@johncrisostomo
johncrisostomo / publication.js
Created May 7, 2018 01:13
gagarin client testing
import { Categories, Products } from '/lib/collections';
import {Meteor} from 'meteor/meteor';
import {check} from 'meteor/check';
export default function () {
Meteor.publish('categoriesList', () => {
return [
Categories.find(),
it('should call Meteor.call to save the post', () => {
const Meteor = {uuid: () => 'id', call: spy()};
const LocalState = {set: spy()};
const FlowRouter = {go: spy()};
actions.create({LocalState, Meteor, FlowRouter}, 't', 'c');
const methodArgs = Meteor.call.args[0];
expect(methodArgs.slice(0, 4)).to.deep.equal([
'posts.create', 'id', 't', 'c'
create({Meteor, LocalState, FlowRouter}, title, content) {
if (!title || !content) {
return LocalState.set('SAVING_ERROR', 'Title & Content are required!');
}
LocalState.set('SAVING_ERROR', null);
const id = Meteor.uuid();
Meteor.call('posts.create', id, title, content, (err) => {
it('should set SAVING_ERROR with the error message', () => {
const Meteor = {uuid: () => 'id', call: stub()};
const LocalState = {set: spy()};
const FlowRouter = {go: spy()};
const err = {message: 'Oops'};
Meteor.call.callsArgWith(4, err);
actions.create({Meteor, LocalState, FlowRouter}, 't', 'c');
expect(LocalState.set.args[1]).to.deep.equal([ 'SAVING_ERROR', err.message ]);
});