Skip to content

Instantly share code, notes, and snippets.

View sergenes's full-sized avatar
🏠
Working from home

Sergey Nes sergenes

🏠
Working from home
View GitHub Profile
@sergenes
sergenes / Old Android RTL Alignment
Last active December 21, 2015 12:18
Old Android, how to understand that you have to fix alignment in TextView.
public class SplashActivity extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.splash);
LinearLayout layoutMain = (LinearLayout) findViewById(R.id.layoutMain);
#pragma mark - NetworkHelper.h
- (void)getHotspotNameWithCompletion:(void (^)(void))completionBlock andFail:(void (^)(void))failBlock;
#pragma mark - NetworkHelper.m
- (void)getHotspotNameWithCompletion:(void (^)(void))completionBlock andFail:(void (^)(void))failBlock
{
dispatch_async(queue, ^{
@sergenes
sergenes / gist:374991e4d1b13a580432
Last active August 29, 2015 14:03
How to use SSH private keys on Mac OS X
On Mac OSX, the native SSH client can use the built-in keychain directly. To add your private key to the keychain simply use the command:
ssh-add -K /path/of/private/key
As an example if your private key is stored at ~/.ssh and is named id_rsa, you would use the command:
ssh-add -K ~/.ssh/id_rsa
You will then be prompted for your passcode, which will be stored in your keychain. After this you should be ready for a password-less login.
@sergenes
sergenes / gist:3e8cf67b771c9bca3b5d
Created August 5, 2014 06:40
Reset Storyboard to Initial View Controller
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
_initalStoryboard = self.window.rootViewController.storyboard;
}
-(void) resetStoryBoard{
"Android development War Stories"
1. Android Development War Stories by Lope Emano April-June 2014
2. Seriously though.
3. The Format Share and discuss experiences in an app you’ve built and/or the new things you’ve learned the past few months.
4. Things I’ve learned the past few months
5. New Design-First process is kewl First two weeks: ❖ Researched existing similar apps (advantages and disadvantages) ❖ Watched Android Design In Action videos ❖ Sketched designs/layouts using pencil and paper via printed out stencil kit
6. New Design-First process is kewl ❖ Demo app to product owner in front of photoshop for insta changes ❖ Acquaint designer with terms like "actionbar, navigation bar, status bar, overflow" for easy communication ❖ Android asset studio ❖ Look around for potential tools
7. Libraries
8. Guava - Light and useful - Used only MultiMap and StringUtils - Still have a lot to learn!
9. No need for ActionBarSherlock - Android support library can now suffice
1. Building Scalable Stateless Applications with RxJava Rick Warren | Principal Engineer, eHarmony [email protected] | @DangerLemming
2. RxJava • Encapsulates data sequences: Observable • Provides composable operations on them • Abstracts away threading and synch • Port from Microsoft .NET Reactive Extensions • Java 6+, Groovy, Clojure, JRuby, Kotlin, and Scala; Android-compatible
3. Netflix Client Client Client Client Client Coarse-Grained API Orchestration Layer Mi- -cro Ser- -vic- -es
4. Applicability Application or Presentation-Layer Service Client Client Client Client Client Data Source Data Source Data Source Data Source Data Source
5. 3 Problems 1. Streaming queries 2. Rate-limited APIs (with retries) 3. Using Futures
6. Streaming Queries Data Store Service Client 1 2 3 1. Query lots of data from NoSQL store 2. Enrich, filter, and score on the fly 3. Deliver “best” results to client
7. Streaming Queries 1 Query 2 Enrich 3 Deliver + = Too Much Latency
8. Streaming Queries 1 Query && = 2 Enrich 3 Deli
@sergenes
sergenes / gist:9ebee9d91c75b5cde7d7
Created March 9, 2016 07:52
Android - Fragment - show/hide keyboard event and move up the main layout
Rect visibleRect = new Rect();
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
ViewGroup mMain = (ViewGroup) inflater.inflate(R.layout.select_cover_album, container, false);
mMain.getWindowVisibleDisplayFrame(visibleRect);
mMain.addOnLayoutChangeListener(new View.OnLayoutChangeListener() {
@Override
@sergenes
sergenes / nodejs-tcp-example.js
Created August 13, 2016 02:06 — forked from tedmiston/nodejs-tcp-example.js
Node.js tcp client and server example
/*
In the node.js intro tutorial (http://nodejs.org/), they show a basic tcp
server, but for some reason omit a client connecting to it. I added an
example at the bottom.
Save the following server in example.js:
*/
var net = require('net');
@sergenes
sergenes / bluetooth-raspberry-pi-communication.py
Created August 27, 2018 13:46 — forked from keithweaver/bluetooth-raspberry-pi-communication.py
Sending information with bluetooth on Raspberry Pi (Python)
# Uses Bluez for Linux
#
# sudo apt-get install bluez python-bluez
#
# Taken from: https://people.csail.mit.edu/albert/bluez-intro/x232.html
# Taken from: https://people.csail.mit.edu/albert/bluez-intro/c212.html
import bluetooth
def receiveMessages():
class Node<T>(var data: T, var nextNode: Node<T>? = null)
class LinkedList<T> {
var size: Int = 0
var head: Node<T>? = null
//O(1)
fun insertStart(data: T) {
size += 1
val newNode = Node(data = data)