Skip to content

Instantly share code, notes, and snippets.

@Kozlov-V
Kozlov-V / fscreen.java
Created February 24, 2015 18:00
To create always-top fullscreen overlay activity in Android
final WindowManager.LayoutParams params = new WindowManager.LayoutParams(
WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.TYPE_SYSTEM_ALERT,
WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN,
PixelFormat.TRANSLUCENT);
WindowManager wm = (WindowManager) getApplicationContext()
.getSystemService(Context.WINDOW_SERVICE);
@Kozlov-V
Kozlov-V / example.m
Last active June 18, 2021 03:39
upload task in background using afnetworking + progress
Use:
NSURLSessionConfiguration:backgroundSessionConfiguration:
instead of
NSURLSessionConfiguration:defaultSessionConfiguration
From the NSURLSessionConfiguration:backgroundSessionConfiguration: documentation:
Upload and download tasks in background sessions are performed by an external daemon instead of by the app itself. As a result, the transfers continue in the background even if the app is suspended, exits, or crashes.
So in your case, change:
@Kozlov-V
Kozlov-V / gist:6129942
Last active September 13, 2016 02:56
Android Button
public class Demo extends Activity {
private View.OnClickListener curlPostListener;
private Button curlPost;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
InitializeApp();
}
@Kozlov-V
Kozlov-V / uploadtask.m
Last active June 24, 2016 09:09
NSURLSessionUploadTask
2.3).NSURLSessionUploadTask
Upload Task sends data/file and it supports background uploads when the app is not running.
2.3.1) Create Upload task with system provided delegate methods.
/* Creates an upload task with the given request. The body of the request will be created from the file referenced by fileURL */
- (NSURLSessionUploadTask *)uploadTaskWithRequest:(NSURLRequest *)request fromFile:(NSURL *)fileURL;
/* Creates an upload task with the given request. The body of the request is provided from the bodyData. */
- (NSURLSessionUploadTask *)uploadTaskWithRequest:(NSURLRequest *)request fromData:(NSData *)bodyData;
#!/bin/bash
set -e
## Utils
print_msg() {
echo "Frappe password: $FRAPPE_USER_PASS"
echo "MariaDB root password: $MSQ_PASS"
%% @author Masahito Ikuta <cooldaemon@gmail.com> [http://d.hatena.ne.jp/cooldaemon/]
%% @copyright Masahito Ikuta 2008
%% @doc UDP Server Behaviour.
%% Copyright 2008 Masahito Ikuta
%%
%% Licensed under the Apache License, Version 2.0 (the "License");
%% you may not use this file except in compliance with the License.
%% You may obtain a copy of the License at
%%
<resources>
<!-- Style you can use with a container (typically a horizontal
LinearLayout) to get the standard "button bar" background and
spacing. @hide -->
<style name="ButtonBar">
<item name="android:paddingTop">5dip</item>
<item name="android:paddingStart">4dip</item>
<item name="android:paddingEnd">4dip</item>
<item name="android:paddingBottom">1dip</item>
<item name="android:background">@android:drawable/bottom_bar</item>
@Kozlov-V
Kozlov-V / actionModule
Last active December 22, 2015 00:19
ActionProcessing
P = spawn(actionModule,doAction1, [Params]),
P ! {self(), "Hello"}.
receive
{StartDoAction2} ->
doAction2(Params),
P2 =spawn(actionModule,doAction3, [Params]),
end.
doAction2(Params) -> doAnyAction. %% Выполнение POST запроса, ожидаем ответ 200
@Kozlov-V
Kozlov-V / file_list.java
Created August 2, 2013 13:33
FIle dir to list
void ================================================
File dir = new File ("data/user/VRP");
List<File> files = null;
try {
files = getFileListing(dir);
} catch (FileNotFoundException e) {
e.printStackTrace();
}
======================================================
static public List<File> getFileListing(
@Kozlov-V
Kozlov-V / file_to_ins.java
Last active December 20, 2015 13:19
file to inputstream
File file = ...
InputStream in = null;
try {
in = new BufferedInputStream(new FileInputStream(file));
} catch (FileNotFoundException e1) {
e1.printStackTrace();
} finally {
if (in != null) {
try {
in.close();