Skip to content

Instantly share code, notes, and snippets.

@ilyi1116
ilyi1116 / cmd.sh
Created August 13, 2021 08:50 — forked from kelvinn/cmd.sh
Example of using Apache Bench (ab) to POST JSON to an API
# post_loc.txt contains the json you want to post
# -p means to POST it
# -H adds an Auth header (could be Basic or Token)
# -T sets the Content-Type
# -c is concurrent clients
# -n is the number of requests to run in the test
ab -p post_loc.txt -T application/json -H 'Authorization: Token abcd1234' -c 10 -n 2000 http://example.com/api/v1/locations/
@ilyi1116
ilyi1116 / ts-to-mp4.py
Created April 24, 2018 13:36 — forked from nhtera/ts-to-mp4.py
Convert all videos .ts to .mp4 using ffmpeg
#!/usr/local/opt/python/bin/python2.7
# Required ffmpeg
import os
import sys
walk_dir = os.getcwd()
count = 0
for root, subdirs, files in os.walk(walk_dir):
for file in files:
@ilyi1116
ilyi1116 / ts-to-mp4.py
Created April 24, 2018 13:36 — forked from nhtera/ts-to-mp4.py
Convert all videos .ts to .mp4 using ffmpeg
#!/usr/local/opt/python/bin/python2.7
# Required ffmpeg
import os
import sys
walk_dir = os.getcwd()
count = 0
for root, subdirs, files in os.walk(walk_dir):
for file in files:
@ilyi1116
ilyi1116 / StopJumpingTableViewOnInsertRows.swift
Created January 24, 2018 03:51 — forked from joshdholtz/StopJumpingTableViewOnInsertRows.swift
Used when loading more data into UITableView for a smooth "infinite scroll" feel
// I dont want my table jumping/animation when appending new rows
// for an infinite scroll feel
//
// Some of this might not be needed but it works
//
// TODO: Possibly garbage
extension UITableView {
func reloadDataSmoothly() {
UIView.setAnimationsEnabled(false)
@ilyi1116
ilyi1116 / VIPER Android Example.kt
Created July 20, 2017 01:12 — forked from marciogranzotto/VIPER Android Example.kt
This is an example of Android development with VIPER in Kotlin
interface LoginContracts {
interface View {
fun showError(message: String)
}
interface Presenter {
fun onDestroy()
fun onLoginButtonPressed(username: String, password: String)
}
@ilyi1116
ilyi1116 / Log.h
Created May 22, 2017 14:37 — forked from olxios/Log.h
How to use NSLog and print only for debugging? http://swiftiostutorials.com/use-nslog-debugging/
#import <Foundation/Foundation.h>
@interface Log : NSObject
extern void SSLog(BOOL releaseLog, NSString *format, ...) NS_FORMAT_FUNCTION(2,3);
@end
@ilyi1116
ilyi1116 / textHeight.m
Created May 19, 2017 15:12 — forked from brennanMKE/textHeight.m
Text Height in Objective-C for NSString and NSAttributedString
- (CGFloat)heightForAttributedString:(NSAttributedString *)text maxWidth:(CGFloat)maxWidth {
if ([text isKindOfClass:[NSString class]] && !text.length) {
// no text means no height
return 0;
}
NSStringDrawingOptions options = NSStringDrawingUsesLineFragmentOrigin | NSStringDrawingUsesFontLeading;
CGSize size = [text boundingRectWithSize:CGSizeMake(maxWidth, CGFLOAT_MAX) options:options context:nil].size;
@ilyi1116
ilyi1116 / CFCustomeImageView.h
Created May 19, 2017 15:12 — forked from tobitech/CFCustomeImageView.h
This is a UIImageView Subclass that has caching support. Good for use in TableViews and CollectionViews cells
//
// CFCustomeImageView.h
//
// Created by Tobi Omotayo on 24/10/2016.
// Copyright © 2016 Tobi Omotayo. All rights reserved.
//
#import <UIKit/UIKit.h>
@interface CFCustomeImageView : UIImageView {
@ilyi1116
ilyi1116 / reverseAuth.m
Created May 19, 2017 15:10 — forked from YarGnawh/reverseAuth.m
Twitter Reverse Auth API Request
- (void)reserveAuth
{
NSString * http_method = @"POST";
NSString * request_url = @"https://api.twitter.com/oauth/request_token";
NSString * oauth_consumer_key = @"bcn3PUKI0PZoxfPTqEDkMru9A";
NSString * oauth_consumer_secret = @"YiVeSteQBplk8xzAtuoulA7i2vLkVF5kIwc5x1A6ZaxmugdmXg";
NSString * oauth_nonce = [[NSUUID UUID] UUIDString];
NSString * oauth_signature = @"";
NSString * oauth_signature_method = @"HMAC-SHA1";
@implementation UIImageView (Asynchronous)
+ (instancetype _Nonnull)imageViewWithURL:(NSString * _Nonnull )url {
return [self imageViewWithURL:url completionHandler:nil];
}
+ (instancetype _Nonnull)imageViewWithURL:(NSString * _Nonnull )url
completionHandler:(completionHandler _Nullable)block {
UIImageView *imageView = [UIImageView new];
[imageView loadImageWithURL:url completionHandler:block];