Skip to content

Instantly share code, notes, and snippets.

View saiday's full-sized avatar
:shipit:
su su su

Saiday saiday

:shipit:
su su su
View GitHub Profile
@saiday
saiday / server.py
Created December 22, 2018 12:26
user-agent viewer server
#!/usr/bin/env python
from http.server import SimpleHTTPRequestHandler
from socketserver import TCPServer
import logging
PORT = 8000
class GetHandler(SimpleHTTPRequestHandler):
...
@Override
public void setPrimaryItem(@NonNull ViewGroup container, int position, @NonNull Object object) {
super.setPrimaryItem(container, position, object);
NestedScrollView current = ((NestedScrollView)object);
current.setNestedScrollingEnabled(true);
for (int i = 0; i < getCount(); i++) {
if (i != position) {
NestedScrollView otherScrollView = container.findViewWithTag(i);
@saiday
saiday / mp4_to_gif.sh
Last active July 29, 2019 06:57
convert mp4 video to gif
# dependencies:
# - ffmpeg
# - imagemagick
# Usage:
mkdir mp4_to_gif
ffmpeg -i myfile.mp4 -vf scale=1024:-1:flags=lanczos,fps=10 mp4_to_gif/ffout%03d.png
convert -loop 0 mp4_to_gif/ffout*.png output.gif
rm -rf mp4_to_gif
@saiday
saiday / playground.go
Created February 11, 2018 12:41
Golang remove first differences between slice value and pointer
package main
import "fmt"
func main() {
s := []int{2, 3, 5, 7, 11, 13}
printSlice(s)
removeFirst(s)
printSlice(s)
@saiday
saiday / MockitoConfiguration.java
Created January 27, 2018 16:32
MockitoConfiguration
package org.mockito.configuration;
import org.mockito.internal.stubbing.defaultanswers.ReturnsEmptyValues;
import org.mockito.invocation.InvocationOnMock;
import org.mockito.stubbing.Answer;
import rx.Observable;
import rx.Single;
/**
@saiday
saiday / script.bash
Created April 25, 2017 19:06
Add specific GoogleService-Info.plist
if [ "${CONFIGURATION}" == "Release" ]; then
cp -r "${PROJECT_DIR}/{PATH}/GoogleService-Info-release.plist" "${BUILT_PRODUCTS_DIR}/${PRODUCT_NAME}.app/GoogleService-Info.plist"
echo "Production plist copied"
elif [ "${CONFIGURATION}" == "Debug" ]; then
cp -r "${PROJECT_DIR}/{PATH}/GoogleService-Info-debug.plist" "${BUILT_PRODUCTS_DIR}/${PRODUCT_NAME}.app/GoogleService-Info.plist"
echo "Development plist copied"
@saiday
saiday / AndroidManifest.xml
Created March 21, 2017 14:48
Android Intents on manifest
<activity ..>
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="http" />
<data android:scheme="https" />
<data android:host="www.mysite.com" />
</intent-filter>
</activity>
@saiday
saiday / gist:972b073bcdda6bfbb0217ace0303f220
Created January 19, 2017 08:38
Codecov coverage issue
This file has been truncated, but you can view the full file.
travis_fold:start:worker_info
Worker information
hostname: travis-worker-gce-com-prod2-1:94376007-71e0-467f-98cb-8122cf852888
version: v2.5.0 https://github.com/travis-ci/worker/tree/da3a43228dffc0fcca5a46569ca786b22991979f
instance: testing-gce-37d82fd8-fa7e-47d8-9278-88a7e48f39cb:travis-ci-android-precise-1478744927
startup: 21.129647774s
travis_fold:end:worker_info
travis_fold:start:system_info
Build system information
Build language: android
...
- (BOOL)application:(UIApplication *)application
openURL:(NSURL *)url
sourceApplication:(NSString *)sourceApplication
annotation:(id)annotation
{
// imnotyourson://article/123, imnotyourson://user/123
if ([url.scheme isEqualToString:@"imnotyourson"]) {
NSURLSessionDataTask *task = [[NSURLSession sharedSession] dataTaskWithURL:url completionHandler:^(NSData * _Nullable data, NSURLResponse * _Nullable response, NSError * _Nullable error) {
dispatch_async(dispatch_get_main_queue(), ^{
#import "ImnotyoursonURLProtocol.h"
#import "User.h"
#import "Article.h"
#import "GenericItem.h"
@implementation ImnotyoursonURLProtocol
+ (BOOL)canInitWithRequest:(NSURLRequest *)request
{