Skip to content

Instantly share code, notes, and snippets.

View AlexGladkov's full-sized avatar
🦆
Quack Quack

Alex AlexGladkov

🦆
Quack Quack
View GitHub Profile
@AlexGladkov
AlexGladkov / NSURLSession.m
Last active March 2, 2016 15:50
Apple Snippet NSURLSession
-(void)URLPostRequest:(NSString *)stringData success:(void (^)(id responseDict))success failure:(void (^)(NSString *error))failure {
NSURL *url = [NSURL URLWithString:@"yoururladdresshere"]; //Set the url
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url cachePolicy:NSURLRequestUseProtocolCachePolicy timeoutInterval:60.0]; // Set Timeout Interval = 1 minute
[request setValue:@"text/json; charset=utf-8" forHTTPHeaderField:@"Content-Type"]; // Set Charset Type
[request addValue:@"application/json" forHTTPHeaderField:@"Accept"]; // Set Packet Type
request.HTTPMethod = @"POST"; // Set Method
request.HTTPBody = [stringData dataUsingEncoding:NSUTF8StringEncoding]; // Our data to Post
public class AlarmBroadcast extends BroadcastReceiver {
final public static String ONE_TIME = "onetime";
//При получении сигнала о срабатывании уведомления
@Override
public void onReceive(Context context, Intent intent) {
PowerManager pm = (PowerManager) context.getSystemService(Context.POWER_SERVICE); //Получаем соответствующий сервис
PowerManager.WakeLock wl = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "Ваше сообщение в уведомлении"); // Создаем уведомление
#import "ASCIICounter.h"
static const int kASCIISymbolsCount = 256;
char* fillMappingArrayInSequence(char* str, int size, char* asciiMappingArray) {
for (int currentSymbolPosition = 0; currentSymbolPosition < size; currentSymbolPosition++) {
asciiMappingArray[str[currentSymbolPosition]]++;
}
return asciiMappingArray;
public static async Task WriteToFile(string key, string foldername, string filename)
{
// Get the text data from the textbox.
byte[] fileBytes = System.Text.Encoding.UTF8.GetBytes(key.ToCharArray());
// Get the local folder.
StorageFolder local = Windows.Storage.ApplicationData.Current.LocalFolder;
// Create a new folder name DataFolder.
var dataFolder = await local.CreateFolderAsync(Path.Combine("DataFolder", foldername), CreationCollisionOption.OpenIfExists);
// Create a new file named DataFile.txt.
var file = await dataFolder.CreateFileAsync(filename, CreationCollisionOption.ReplaceExisting);
@Override public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
switch (requestCode) {
case LOCATION_REQUEST: {
if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
viewModel.setLocationState(ComposeViewModel.LOCATION_ON);
mFusedLocationClient = LocationServices.getFusedLocationProviderClient(mActivity);
if (ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) !=
PackageManager.PERMISSION_GRANTED &&
//
// BaseRouting.swift
// sddclient
//
// Created by Гладков Алексей on 10.04.18.
// Copyright © 2018 SDD LLC. All rights reserved.
//
import Foundation
import UIKit
//
// SubscriptionsRouter.swift
// sddclient
//
// Created by Гладков Алексей on 10.04.18.
// Copyright © 2018 SDD LLC. All rights reserved.
//
import Foundation
import UIKit
import io.reactivex.Observable
import io.reactivex.Single
import ru.sddhelp.base.BaseConverter
import ru.sddhelp.data.providers.models.ApiLogin
import ru.sddhelp.data.providers.models.ApiPhone
import ru.sddhelp.data.providers.models.ApiResponse
import ru.sddhelp.data.providers.services.RemoteLoginService
import javax.inject.Inject
/**
package ru.sddhelp.data.providers.services
import io.reactivex.Observable
import io.reactivex.Single
import retrofit2.http.Field
import retrofit2.http.FormUrlEncoded
import retrofit2.http.POST
import ru.sddhelp.data.providers.models.ApiId
import ru.sddhelp.data.providers.models.ApiOrder
import ru.sddhelp.data.providers.models.ApiResponse
import bsh.StringUtil
import io.reactivex.Observable
import io.reactivex.Single
import ru.sddhelp.data.providers.LoginProvider
import ru.sddhelp.data.providers.LoginProviderImpl
import ru.sddhelp.data.providers.ProfileProvider
import ru.sddhelp.data.providers.ProfileProviderImpl
import ru.sddhelp.data.providers.models.*
import ru.sddhelp.domain.contracts.RemoteContract
import ru.sddhelp.domain.repositories.AuthRepository