Skip to content

Instantly share code, notes, and snippets.

View fabdarice's full-sized avatar

fabda fabdarice

View GitHub Profile
@fabdarice
fabdarice / Donation.sol
Last active July 11, 2019 20:04
Relay contract that contains only one state variable 'user_amounts' - Link first to Donation contract, then update to DonationNew to add the cancelDonation function.
contract Donation {
mapping (address => uint) user_amounts;
/* DOES THIS METHODS MODIFY user_amounts of the Relay contract ??? */
function sendDonation(uint n) {
user_amounts[msg.sender] = user_amounts[msg.sender] + n
}
}
@fabdarice
fabdarice / fabriceriot.rb
Created March 5, 2016 01:47
Fabrice Cheng Riot Games Test
# check if a string a valid by having opening and closed brackets/parenthesis
def is_valid_string(str)
arr = []
str.each_char do |c|
arr.push(c) if c == '{' or c == '[' or c == '('
if c == '}'
# check last element of array - must correspond to '{''
if not arr.empty? and arr[-1] == '{'
java.lang.RuntimeException: retrofit.converter.ConversionException: com.google.gson.JsonSyntaxException: java.lang.IllegalStateException: Expected BEGIN_OBJECT but was STRING at line 1 column 1 path $
at com.Challfie.android.challfiefragment.AddChallfieFinalActivity$7.failure(AddChallfieFinalActivity.java:415)
at retrofit.CallbackRunnable$2.run(CallbackRunnable.java:53)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5424)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:913)
@fabdarice
fabdarice / gist:6e899f88a02dfa049fbd
Created November 12, 2015 07:33
CAPSPageMenu.swift
// CAPSPageMenu.swift
//
// Niklas Fahl
//
// Copyright (c) 2014 The Board of Trustees of The University of Alabama All rights reserved.
//
// Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
//
// Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
//
@fabdarice
fabdarice / gist:4cd0755aa6dc0555db45
Created November 12, 2015 06:55
MatchupVC.swift
class MatchupsVC: UIViewController {
var pageMenu : CAPSPageMenu?
override func viewDidLoad() {
super.viewDidLoad()
// Hide on swipe & keboard Appears
self.navigationController?.hidesBarsOnSwipe = false
self.navigationController?.navigationItem.backBarButtonItem = UIBarButtonItem(title: "", style: UIBarButtonItemStyle.Plain, target: nil, action: nil)
{
"matchups" : [
{
"challenges" : [
{
"difficulty" : 1,
"id" : 168,
"complete_status" : 2,
"description" : "Prendre un selfie avec tes collègues ou camarades de classe"
}
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.challfie.android/com.Challfie.android.challfiefragment.AddChallfieTakePictureActivity}: java.lang.RuntimeException: Fail to connect to camera service
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2305)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2365)
at android.app.ActivityThread.access$800(ActivityThread.java:148)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1283)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5272)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
public static Bitmap decodeSampledBitmapFromResource(Resources res, int resId,
int reqWidth) {
// First decode with inJustDecodeBounds=true to check dimensions
final BitmapFactory.Options options = new BitmapFactory.Options();
options.inJustDecodeBounds = true;
BitmapFactory.decodeResource(res, resId, options);
// Calculate inSampleSize
options.inSampleSize = calculateInSampleSize(options, reqWidth);
Bitmap myBitmap = BitmapFactory.decodeFile(picturePath);
Bitmap resized = Bitmap.createScaledBitmap(myBitmap, myBitmap.getWidth() / 2, myBitmap.getHeight() / 2, true); // TO AVOID OUT OF MEMORY FOR HIGH RESOLUTION PICTURE
rotated_photo = rotateBitmap(resized)
public static Bitmap rotateBitmap(Bitmap bitmap) {
ExifInterface exif = null;
try {
exif = new ExifInterface(bitmap);
} catch (IOException e) {
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
// Override point for customization after application launch.
self.window = UIWindow(frame: UIScreen.mainScreen().bounds)
let mainStoryboard: UIStoryboard = UIStoryboard(name: "Main", bundle: nil)
var loginViewController:LoginVC = mainStoryboard.instantiateViewControllerWithIdentifier("loginVC") as! LoginVC
var timelineViewController:TimelineVC = mainStoryboard.instantiateViewControllerWithIdentifier("timeline") as! TimelineVC
let login = KeychainInfo.login
let auth_token = KeychainInfo.auth_token