Skip to content

Instantly share code, notes, and snippets.

View densa's full-sized avatar
🇺🇦
UKE

Denys Sedura densa

🇺🇦
UKE
View GitHub Profile
@densa
densa / UIToolbar+CustomBackground.h
Created June 15, 2011 11:58
Custom background for UIToolbar w/ UINavigationBar
@interface UIToolbar (CustomImage)
@end
@densa
densa / UIImage+FixOrient.m
Created July 5, 2011 10:56
UIImage fix orientation
- (UIImage *)fixOrientation {
// No-op if the orientation is already correct
if (self.imageOrientation == UIImageOrientationUp) return self;
// We need to calculate the proper transformation to make the image upright.
// We do it in 2 steps: Rotate if Left/Right/Down, and then flip if Mirrored.
CGAffineTransform transform = CGAffineTransformIdentity;
switch (self.imageOrientation) {
@densa
densa / .m
Created August 22, 2011 08:04
iphone memory usage
#import mach/mach.h
void report_memory(void) {
struct task_basic_info info;
mach_msg_type_number_t size = sizeof(info);
kern_return_t kerr = task_info(mach_task_self(),
TASK_BASIC_INFO,
(task_info_t)&info,
&size);
if( kerr == KERN_SUCCESS ) {
@densa
densa / .m
Created December 16, 2011 08:55
Phone formatter
self.mask = @"111-222-3333";
- (BOOL)textField:(UITextField *)textField
shouldChangeCharactersInRange:(NSRange)range
replacementString:(NSString *)string
{
if (textField.tag == 5)
{
//If the length of used entered text is equals to mask length the user input must be cancelled
@densa
densa / gist:4632803
Created January 25, 2013 08:31
WiFi info
#import <SystemConfiguration/CaptiveNetwork.h>
- (id)fetchSSIDInfo
{
NSArray *ifs = (__bridge id)CNCopySupportedInterfaces();
NSLog(@"%s: Supported interfaces: %@", __func__, ifs);
id info = nil;
for (NSString *ifnam in ifs) {
info = (__bridge id)CNCopyCurrentNetworkInfo((__bridge CFStringRef)ifnam);
NSLog(@"%s: %@ => %@", __func__, ifnam, info);
@densa
densa / gist:3fb0fea6f135e5412aab
Created April 10, 2015 09:13
findPointOnTangentOnCircleWithCenter
+(double)distanceBetweenPoint:(CGPoint)pointA andAnotherPoint:(CGPoint)pointB
{
return sqrt((pointA.x - pointB.x)*(pointA.x - pointB.x) + (pointA.y - pointB.y)*(pointA.y - pointB.y));
}
+(NSArray *)findPointOnTangentOnCircleWithCenter:(CGPoint)center Radius:(double)radius pointOnTangent:(CGPoint)point
{
double dx = center.x - point.x;
double dy = center.y - point.y;
double distance = [EXMathBrain distanceBetweenPoint:center andAnotherPoint:point];
# usage: `python ~/Desktop/contours.py 1994-654-12_v02.tif`
# output is to a squareless.txt file and the directory "out"
# Working well with thumbnails with 400px as their longest side - untested with other dimensions
# for i in $(ls -1 | grep tif); do python /Users/artsyinc/Documents/resistance/experiments/artwork_image_cropping/contours.py $i; done
import cv2
import numpy as np
from matplotlib import pyplot as plt
import sys
const blacklist = require('metro-bundler/src/blacklist');
module.exports = {
getBlacklistRE: function() {
return blacklist([/[^e]\/node_modules\/react-native\/.*/]);
}
};
@densa
densa / gist:e31d71964549731ab20e7dde6b9de65a
Created March 13, 2018 08:04
Fix simulator xcode 8 and xcode 9
launchctl remove com.apple.CoreSimulator.CoreSimulatorService || true
@densa
densa / gist:f1ba0f332db851313fdd19517aeaa101
Created June 13, 2019 12:34
[react-native]could not connect to development server on android
Starting with Android 9.0 (API level 28), cleartext support is disabled by default. we can use android:usesCleartextTraffic="true" this will work but this is not recommended solution. For Permanent and recommended Solution is
Step 1 : create a file in android folder app/src/debug/res/xml/network_security_config.xml
Step 2 : add this <?xml version="1.0" encoding="utf-8"?>
<network-security-config>
<!-- deny cleartext traffic for React Native packager ips in release -->
<domain-config cleartextTrafficPermitted="true">
<domain includeSubdomains="true">localhost</domain>