Skip to content

Instantly share code, notes, and snippets.

View yosriady's full-sized avatar
💡
Optimize for Learning

Yos Riady yosriady

💡
Optimize for Learning
View GitHub Profile
@yosriady
yosriady / watermark.rb
Created October 25, 2014 14:54
Rails Paperclip Multi-page PDF Watermark Processor with MiniMagick
module Paperclip
class Watermark < Processor
WATERMARK_PATH = "#{Rails.root}/public/images/watermark.png"
def initialize(file, options = {}, attachment = nil)
super
@file = file
@watermark_path = options[:watermark_path]
@current_format = File.extname(@file.path)
@basename = File.basename(@file.path, @current_format)
@yosriady
yosriady / magic_box.rb
Created October 26, 2014 15:19
Solution for Palantir Interview Challenge
def read_input
line = STDIN.gets
m, n = line.split(" ").map{|s| s.to_i}
fingerprints = []
m.times do
fingerprints << STDIN.gets.chomp
end
return fingerprints
end
#include "cuPrintf.cu"
#include <stdio.h>
__device__ __host__ int distance(int x1, int y1, int x2, int y2)
{
return (x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2);
}
/* The CPU version of Voronoi Diagram computation */
void cpuVoronoiDiagram(Point2D *points, int *output, int noPoints, int width, int height)
#define MAX_DESIRABILITY 10;
#define NUM_BIDDERS 10;
#define NUM_ITEMS 20;
#define BIDDER_BALANCE 100;
#define YOUR_BALANCE 100;
Seller() = generateBidOrders -> showItem();
showItem() = getAllBidPrices -> announceWinner -> announceWinnerPrice -> showItem();
NormalBidder() = checkDesirability -> checkBalance -> calculatePrice -> bid -> getResults -> updateBalance -> NormalBidder();
@yosriady
yosriady / input.cpp
Last active August 29, 2015 14:08
To run: ./a.out 1 16 5 5 5 4 0 0 glider5554.txt
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
// **********************************************************************************************
//*Global Vars
// **********************************************************************************************
int dp; // Field is displayed every dp generations (0..n)
// "sp" is used to slow down the game - by putting in a timing loop between generations. A value of sp of
// 1000 should do one generation in about 1 second. A value of 0 will do the generation as fast as possible.
void generation_sleep(){
if(sp > 0){
sleep(sp);
}
}
def build_adaptive_payment_request(sheet)
trackingId = generate_token
api = PayPal::SDK::AdaptivePayments::API.new
pay_request = api.build_pay()
pay_request.trackingId = trackingId
pay_request.actionType = "PAY"
pay_request.cancelUrl = orders_cancel_url
pay_request.returnUrl = orders_success_url(trackingId)
pay_request.ipnNotificationUrl = orders_ipn_notify_url
$(document).on("page:change", function() {
UserVoice=window.UserVoice||[];(function(){var uv=document.createElement('script');uv.type='text/javascript';uv.async=true;uv.src='//widget.uservoice.com/1foGiwZkzLazJrcOoI22A.js';var s=document.getElementsByTagName('script')[0];s.parentNode.insertBefore(uv,s)})();
UserVoice.push(['set', {
accent_color: '#448dd6',
trigger_color: 'white',
trigger_background_color: 'rgba(46, 49, 51, 0.6)'
}]);
UserVoice.push(['addTrigger', { mode: 'contact', trigger_position: 'bottom-right' }]);
UserVoice.push(['autoprompt', {}]);
});
@yosriady
yosriady / gist:9323babb34e03d9ae559
Created April 23, 2015 02:58
Ask at 1pm meeting.
Q: Is there a restriction for front-tier APIs to talk to DBs directly? If there is, is it a restriction from Raptor or PPaas? If it's from Raptor, ask for more details.
{"name":"Richard Hendriks","email":"[email protected]","phone":"(912) 555-4321","skills":"HTML, CSS, Javascript\nMpeg, MP4, GIF\nWEB DEVELOPMENT\nCOMPRESSION","experience":"Pied Piper\nCEO/President Dec 2013 - Dec 2014\nPied Piper is a multi-platform technology based on a proprietary universal compression algorithm that has consistently\nfielded high Weisman Scores that are not merely competitive, but approach the theoretical limit of lossless compression.\nBuild an algorithm for artist to detect if their music was violating copy right infringement laws\nSuccessfully won Techcrunch Disrupt\nOptimized an algorithm that holds the current world record for Weisman Scores\nVOLUNTEERING\nCoderDojo\nTeacher Jan 2012 - Jan 2013\nGlobal movement of free coding clubs for young people.\nAwarded 'Teacher of the Month'","education":"University of Oklahoma\nJun 2011 - Jan 2014\nBachelor - Information Technology GPA: 4.0","awards":"Digital Compression Pioneer Award\nundefined NaN\nTechcrunch\nThere is no spoon.\nPUB