This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Location } from 'history'; | |
import { useEffect, useState } from 'react'; | |
import { useHistory } from 'react-router'; | |
const useBrowserBackStack = () => { | |
const history = useHistory(); | |
const [backStack, setBackStack] = useState<Location[]>([]); | |
useEffect(() => { | |
history.listen((location, action) => { | |
setBackStack(backStack => { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.surpriise.vouchrcommon.ui.components; | |
import android.content.Context; | |
import android.database.DataSetObserver; | |
import android.view.LayoutInflater; | |
import android.view.View; | |
import android.view.ViewGroup; | |
import android.widget.ArrayAdapter; | |
import android.widget.ListAdapter; | |
import android.widget.SpinnerAdapter; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private class GameInterface { | |
public void restartGame() { | |
this.webView.evaluateJavascript("restartGame()", null); | |
} | |
public void startGame() { | |
this.webView.evaluateJavascript("startGame()", null); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public OkHttpClient getOkClient() { | |
OkHttpClient.Builder builder = new OkHttpClient.Builder(); | |
builder.addInterceptor(new XHttpMethodOverrideInterceptor()); | |
return builder.build() | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#import <AFNetworking/AFNetworking.h> | |
- (void) requestToken { | |
NSURLSessionConfiguration *configuration = [NSURLSessionConfiguration defaultSessionConfiguration]; | |
AFHTTPSessionManager *manager = [[AFHTTPSessionManager alloc] initWithSessionConfiguration:configuration]; | |
manager.requestSerializer = [AFJSONRequestSerializer serializer]; | |
NSData *plainData = [[NSString stringWithFormat:@"%@:%@", @"YOUR_TOKEN", @"YOUR_SECRET"] dataUsingEncoding:NSUTF8StringEncoding]; | |
NSString *encodedUsernameAndPassword = [plainData base64EncodedStringWithOptions:0]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
TwitterServiceBuilder.getTwitterService().search("test").enqueue(new Callback<ResponseBody>() { | |
@Override | |
public void onResponse(Call<ResponseBody> call, Response<ResponseBody> response) { | |
Toast.makeText(TwitterActivity.this, response.toString(), Toast.LENGTH_LONG).show(); | |
} | |
@Override | |
public void onFailure(Call<ResponseBody> call, Throwable t) { | |
Toast.makeText(TwitterActivity.this, t.toString(), Toast.LENGTH_LONG).show(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os, sys | |
if len(sys.argv) < 4: | |
print "Family you need 3 params, originalFolder, newResFolder, fileName" | |
else: | |
orginalResFolder = sys.argv[1] | |
newResFolder = sys.argv[2] | |
fileNames = sys.argv[3:] | |
print "files to move " + str(fileNames) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Implementation of {@link OnClickListener} that ignores subsequent clicks that happen too quickly after the first one.<br/> | |
* To use this class, implement {@link #onSingleClick(View)} instead of {@link OnClickListener#onClick(View)}. | |
*/ | |
public abstract class OnSingleClickListener implements OnClickListener { | |
private static final String TAG = OnSingleClickListener.class.getSimpleName(); | |
private static final long MIN_DELAY_MS = 500; | |
private long mLastClickTime; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class WindowUtils { | |
public static int getActionBarHeight(Context context) { | |
final TypedArray styledAttributes = context.getTheme().obtainStyledAttributes( | |
new int[]{R.attr.actionBarSize}); | |
int actionBarHeight = (int) styledAttributes.getDimension(0, 0); | |
styledAttributes.recycle(); | |
return actionBarHeight; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#import "UILabel+HTML.h" | |
@implementation UILabel (HTML) | |
- (void) setHtml: (NSString*) html | |
{ | |
// Add font from label | |
NSString* finalHtml = [html stringByAppendingString:[NSString stringWithFormat:@"<style>body{font-family: '%@'; font-size:%fpx;}</style>", | |
self.font.fontName, | |
self.font.pointSize]]; |
NewerOlder