Skip to content

Instantly share code, notes, and snippets.

@jkongie
jkongie / StringTestAPIConsumer.sol
Created September 10, 2020 08:41
Gets the symbol from the CoinGeckoAPI
/** This example code is designed to quickly deploy an example contract using Remix.
* If you have never used Remix, try our example walkthrough: https://docs.chain.link/docs/example-walkthrough
* You will need testnet ETH and LINK.
* - Kovan ETH faucet: https://faucet.kovan.network/
* - Kovan LINK faucet: https://kovan.chain.link/
*/
pragma solidity ^0.6.0;
import "https://raw.githubusercontent.com/smartcontractkit/chainlink/develop/evm-contracts/src/v0.6/ChainlinkClient.sol";
pragma solidity ^0.6.0;
import "@chainlink/contracts/src/v0.6/ChainlinkClient.sol";
contract CoinGeckoConsumer is ChainlinkClient {
address private oracle;
bytes32 private jobId;
uint256 private fee;
uint256 public ethereumPrice;
@jkongie
jkongie / feed.json
Created April 2, 2018 07:40
JS Challenge Feed
{
"total": 100,
"entries": [
{
"title": "Wolf Creek",
"description": "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.",
"programType": "series",
"images": {
"Poster Art": {
"url": "https://streamcoimg-a.akamaihd.net/000/128/61/12861-PosterArt-ec32a81986a45eac7e080112075ab466.jpg",
@jkongie
jkongie / gist:2833635
Created May 30, 2012 03:47
Use a middot for a ul bullet
li:before {
content: '\b7\a0';
position: absolute;
right: 100%;
font-size: 20px;
}
li {
list-style:none;
position:relative;
}
@jkongie
jkongie / routes.rb
Created May 12, 2012 07:05
Homepage routing based on authenticated status.
Reference links
http://robots.thoughtbot.com/post/22605580334/constrain-yourself
https://github.com/hassox/warden/wiki/overview
@jkongie
jkongie / posts_example.rb
Created November 15, 2011 06:24
Solution using query string
# config/routes.rb
resources :posts, :only => [:index]
# post.rb
scope :recommended, where(:recommended => true) # having a guess on your db structure
scope :recent, order('created_at DESC').limit(10)
scope :popular, where(:like_count => true) # again having a guess
# app/controllers/posts_controller.rb
@jkongie
jkongie / edit.html.haml
Created November 14, 2011 03:25
has many :through nested attributes with checkboxes
# Using formtastic but can easily converted to use standard rails form helpers
= semantic_form_for [ @user ] do |f|
= f.semantic_fields_for :user_specialities do |user_speciality|
= user_speciality.inputs do
= user_speciality.input :speciality_id, :as => :hidden
= user_speciality.input :_destroy, :label => user_speciality.object.speciality.name, :as => :boolean, :checked_value => 0, :unchecked_value => 1, :input_html => { checked: !user_speciality.object.new_record? }
@jkongie
jkongie / rename_show.rb
Created September 9, 2011 02:06
TV Show Renaming Script
#!/usr/bin/env ruby
require 'highline/import'
require 'sofa'
class NoMatchFoundError < StandardError; end;
class EpisodeFile
attr_accessor :file, :season, :episode, :extension, :high_def, :valid
@implementation UINavigationBar (CustomImage)
- (void)drawRect:(CGRect)rect {
UIImage *image = [UIImage imageNamed: @"NavigationBar.png"];
[image drawInRect:CGRectMake(0, 0, self.frame.size.width, self.frame.size.height)];
}
@end
@jkongie
jkongie / Dynamic defination of methods
Created August 5, 2010 01:55
Dynamically define methods
# Dynamically define whether a user has a role methods in a nice query language based on User::ROLES
# Eg. Can now call user.admin? or user.billing?
ROLES.each do |role|
method_name = (role + '?').to_sym
send :define_method, method_name do
self.role == role
end
end