Skip to content

Instantly share code, notes, and snippets.

@sprohaszka
sprohaszka / generate-key-curve.md
Created March 31, 2023 14:09
Generate private/public key with elliptic curve

Generate private and public key

Private key:

  openssl ecparam -name secp256k1 -genkey -noout -out sample-priv-key.pem

Public key (from private key):

  openssl ec -in sample-priv-key.pem -pubout > sample-pub-key.pem
@sprohaszka
sprohaszka / adb-text.sh
Last active November 22, 2019 15:46
[ADB add text] #android
adb shell input [text|keyevent]
usage:
input text <string>
input keyevent <event_code>
event_code:
0 --> "KEYCODE_UNKNOWN"
1 --> "KEYCODE_MENU"
2 --> "KEYCODE_SOFT_RIGHT"
3 --> "KEYCODE_HOME"
# Convert p12 to pem
openssl pkcs12 -in cert.p12 -out apple_push_notification.pem -nodes -clcerts
@sprohaszka
sprohaszka / autolayout.swift
Created February 17, 2016 21:59
When having issue with auto layout and custom view
// Remove iOS magic transalations :/
myView.translatesAutoresizingMaskIntoConstraints = false
@sprohaszka
sprohaszka / extract-version.sh
Last active December 16, 2015 14:03
Extract iOS App version number with awk
# Before pipe: extract lines between 2 patterns
# After pipe: `NR` select the line number to print
awk '/CFBundleVersion/ {p=1}; p; /string/ {p=0};' ../Project/Ressources/Info.plist | awk -F "[><]" 'NR==2 {print $3}'
@sprohaszka
sprohaszka / gist:dd8f26acb0a4390eeee9
Created August 7, 2015 11:51
Install dmg or pkg from terminal (command line)
//http://commandlinemac.blogspot.fr/2008/12/installing-dmg-application-from-command.html
hdiutil mount jdk.dmg
sudo installer -pkg /Volumes/JDK\ 7\ Update\ 60/JDK\ 7\ Update\ 60.pkg -dominfo
sudo installer -pkg /Volumes/JDK\ 7\ Update\ 60/JDK\ 7\ Update\ 60.pkg -target the_chosen_domain
hdiutil unmount "/Volumes/Chicken of the VNC/"
@sprohaszka
sprohaszka / XCTestCase+CoreData.m
Last active August 29, 2015 14:20
Adding CoreData to XCTest
@implementation XCTestCase(CoreData)
+ (id)fakeEntityForTests:(Class)clazz {
NSEntityDescription *entityDesc = [NSEntityDescription entityForName:NSStringFromClass(clazz)
inManagedObjectContext:[[self class] managedObjectContextForTests]];
return [[clazz alloc] initWithEntity:entityDesc
insertIntoManagedObjectContext:[[self class] managedObjectContextForTests]];
}
+ (NSManagedObjectContext *)managedObjectContextForTests {
@sprohaszka
sprohaszka / GCD_Timer.m
Last active August 29, 2015 14:19
Create a timer (redundant task) with GCD
static const NUInteger kFrequency = 15; //seconds
dispatch_queue_t queue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_BACKGROUND, 0);
self.timer = dispatch_source_create(DISPATCH_SOURCE_TYPE_TIMER, 0, 0, queue);
if (self.timer) {
dispatch_source_set_timer(self.timer,
dispatch_time(DISPATCH_TIME_NOW, LMConversationHelperPollingFrequency * NSEC_PER_SEC),
kFrequency * NSEC_PER_SEC,
(1ull * NSEC_PER_SEC) / 10);
__weak id weakSelf = self;
@sprohaszka
sprohaszka / gist:925185aba45556c4e776
Last active August 29, 2015 14:06
Android - Sonar

Sonar with Android

Basics

Credential

Administrator:

  • login: admin
  • password: admin
@sprohaszka
sprohaszka / gist:7333655
Created November 6, 2013 10:02
Convert image to bas64 code
openssl base64 -in image.jpg -out file.txt