Skip to content

Instantly share code, notes, and snippets.

View Shilo's full-sized avatar

Shilo Shilo

View GitHub Profile
@Glideh
Glideh / listSubviewsOfView.m
Last active May 25, 2022 02:36
Lists views recursively with indentation for subviews
- (void)listSubviewsOfView:(UIView *)view {
[self listSubviewsOfView:(UIView *)view withPrefix:@""];
}
- (void)listSubviewsOfView:(UIView *)view withPrefix:(NSString *)prefix {
NSArray *subviews = [view subviews];
for (UIView *subview in subviews) {
NSLog(@"%@ %@ (%d %d; %d %d)", prefix, subview.class
, (int)subview.frame.origin.x
, (int)subview.frame.origin.y
, (int)subview.frame.size.width
create dummy images
curl -L "http://dummyimage.com/600x400/000/fff&text=DummyImage%20[01-10]" -o image_#1.png
get page headers
curl --head http://google.com
send parameters to page
curl.exe -L -G "http://yoururl.com" --data-urlencode "text=DESIGN6 daily backup started"
send formdata & files to page
@dduan
dduan / NSAttributedString+SimpleHTMLTag.swift
Created December 7, 2014 05:59
Convert Simple Text With HTML Tags to NSAttributedString
extension NSAttributedString {
func replaceHTMLTag(tag: String, withAttributes attributes: [String: AnyObject]) -> NSAttributedString {
let openTag = "<\(tag)>"
let closeTag = "</\(tag)>"
let resultingText: NSMutableAttributedString = self.mutableCopy() as NSMutableAttributedString
while true {
let plainString = resultingText.string as NSString
let openTagRange = plainString.rangeOfString(openTag)
if openTagRange.length == 0 {
@wenfahu
wenfahu / I love you in X languages.rst
Last active January 20, 2024 00:14
Say "I love you" in X programming languages! And X = 24
/\_/\     /\_/\
=( owo )= =( owo )=

\ ) ( ) ( //

\(_ _ _) (_ _ _)//

  1. C
@myell0w
myell0w / externalKeyboard.m
Last active October 31, 2023 11:21
Detect if there's an external keyboard attached (iOS)
// direct check for external keyboard
+ (BOOL)_isExternalKeyboardAttached
{
BOOL externalKeyboardAttached = NO;
@try {
NSString *keyboardClassName = [@[@"UI", @"Key", @"boa", @"rd", @"Im", @"pl"] componentsJoinedByString:@""];
Class c = NSClassFromString(keyboardClassName);
SEL sharedInstanceSEL = NSSelectorFromString(@"sharedInstance");
if (c == Nil || ![c respondsToSelector:sharedInstanceSEL]) {
@licvido
licvido / app.swift
Created February 3, 2015 23:18
SWIFT: Fade when changing UIImageView's image
let toImage = UIImage(named:"image.png")
UIView.transitionWithView(self.imageView,
duration:5,
options: .TransitionCrossDissolve,
animations: { self.imageView.image = toImage },
completion: nil)
@vinaysshenoy
vinaysshenoy / gist:f54a208ad93b10e94a3a
Created March 1, 2015 06:58
Android check if color is dark
public boolean isColorDark(int color){
double darkness = 1-(0.299*Color.red(color) + 0.587*Color.green(color) + 0.114*Color.blue(color))/255;
if(darkness<0.5){
return false; // It's a light color
}else{
return true; // It's a dark color
}
}
Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\Folder\shell\Unity5]
@=""
"Icon"="%ProgramFiles%\\Unity\\Editor\\Unity.exe"
"MUIVerb"="Open as Unity Project"
[HKEY_CLASSES_ROOT\Folder\shell\Unity5\Command]
@="cmd /c start /D\"c:\\Program Files\\Unity\\Editor\\\" Unity.exe -projectPath \"%1\""
@leemorgan
leemorgan / Clamp.swift
Last active November 9, 2022 15:36
clamp() in Swift
///Returns the input value clamped to the lower and upper limits.
func clamp<T: Comparable>(value: T, lower: T, upper: T) -> T {
return min(max(value, lower), upper)
}
//-----------------------------------------------
// Example usage
let proposedIndex = 6
@ftvs
ftvs / PhonecallReceiver.java
Last active October 11, 2023 10:05
Detecting an incoming call coming to an Android device. Remember to set the appropriate permissions in AndroidManifest.xml as suggested in the Stackoverflow link. Usage example in comments. Source: Gabe Sechan http://stackoverflow.com/a/15564021/264619 Explanation: http://gabesechansoftware.com/is-the-phone-ringing/#more-8
package com.gabesechan.android.reusable.receivers;
import java.util.Date;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.telephony.TelephonyManager;
public abstract class PhonecallReceiver extends BroadcastReceiver {