Skip to content

Instantly share code, notes, and snippets.

@squm
squm / gist:4653957
Created January 28, 2013 08:40
how to put text to the right of image ?
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context=".MainActivity" >
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="0dp"
case DIALOG_LIST:
return new AlertDialog.Builder(AlertDialogSamples.this)
.setTitle(R.string.select_dialog)
.setItems(R.array.select_dialog_items, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
/* User clicked so do some stuff */
String[] items = getResources().getStringArray(R.array.select_dialog_items);
new AlertDialog.Builder(AlertDialogSamples.this)
.setMessage("You selected: " + which + " , " + items[which])
#import "DefaultViewController.h"
@interface DefaultViewController ()
@end
@implementation DefaultViewController
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
<?xml version="1.0" encoding="utf-8"?>
<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
<string name="app_name">Network Log</string>
<string name="tab_log">Журнал</string>
<string name="tab_apps">Apps</string>
<string name="app_instructions">Соединения - одно нажатие, график - нажмите и придержите</string>
<!-- <string name="app_instructions">Press for connections, long-press for graph</string> -->
<string name="app_packets">Пакеты\u0020</string>
filetype plugin on
map <silent> <F2> :update<CR>
imap <silent> <F2> <Esc>:update<CR>
"set clipboard+=unnamed
set cursorline
normal zR
set nowrap
if v:progname =~? "evim"
finish
endif
@squm
squm / perl.vim
Created March 1, 2013 07:09
vim perl ftplugin
" Make sure the continuation lines below do not cause problems in
" compatibility mode.
set iskeyword+=_
let s:save_cpo = &cpo
set cpo-=C
let g:perldoc_program = 'perldoc'
if !exists("t:plsourcerun")
let t:plsourcefile = expand("%:p")
keepalt botright 6new
let t:plsourcerun = bufnr("%")
@squm
squm / assoc-background.c
Created March 11, 2013 06:06
Operator Precedence and Associativity Rules in C
#include<stdlib.h>
#include<X11/Xlib.h>
#include<string.h>
#include<stdio.h>
#define NCOLORS 3
const char *const assoc[] = {
"() function call left-to-right",
"[] array element ",
". structure or union member ",
@squm
squm / dictionary keys
Created November 29, 2013 12:02
How safe is @1 as dictionary key. NSInteger, NSUInteger int32_t will always map to the same key?
typedef NS_ENUM(int32_t, CFG) {
CFG10,
CFG20,
CFG30
};
NSDictionary *const cfgToString = @{
@(CFG10) : @"CFG10",
@(CFG20) : @"CFG20",
@(CFG30) : @"CFG30"
@squm
squm / tableview_index.m
Last active January 2, 2016 11:29
animates well
selectOptions = [NSMutableIndexSet new];
// …
- (UITableViewCell *)
tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
const NSUInteger row = indexPath.row;
// …
@squm
squm / secure_coding.m
Created January 31, 2014 10:41
secure coding
typedef NS_ENUM(int32_t, CFGGame) {
CFGGameWinter,
CFGGameSummer,
CFGGameVivaldi
};
@interface Person : NSObject <NSSecureCoding>
@property int32_t cfgVersion;
@property (retain, nonatomic) NSDictionary *cfgReserved;