Skip to content

Instantly share code, notes, and snippets.

View fabdarice's full-sized avatar

fabda fabdarice

View GitHub Profile
def create
@product = Product.new(product_params)
@product.save
respond_to do |format|
format.html { render :nothing => true }
format.js { }
end
end
def destroy
@fabdarice
fabdarice / gist:a4006a97171cc415892e
Last active August 29, 2015 14:28
SENDING IMAGE ENCODE BASE64
private void AddNewImage() {
String baos = GetByteArray();
MultipartTypedOutput multipartTypedOutput = new MultipartTypedOutput();
multipartTypedOutput.addPart("login", new TypedString(credential.getUsername()));
multipartTypedOutput.addPart("mobile_upload_file", new TypedString("data:image/jpeg;base64,"+baos));
SetNewImage(multipartTypedOutput);
}
public String GetByteArray() {
File f = getTempFile();
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
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) {
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);
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)
{
"matchups" : [
{
"challenges" : [
{
"difficulty" : 1,
"id" : 168,
"complete_status" : 2,
"description" : "Prendre un selfie avec tes collègues ou camarades de classe"
}
@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)
@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.
//
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)