Skip to content

Instantly share code, notes, and snippets.

View enisinanaj's full-sized avatar
🎯
Focusing

Eni Sinanaj enisinanaj

🎯
Focusing
View GitHub Profile
@enisinanaj
enisinanaj / cachecleaner.php
Created December 8, 2019 17:26
CacheCleaner WordPress plugin
<?php
/**
* Varnish Cache Cleaner.
*
* @package Cache_Cleaner
* @author Eni Sinanaj <[email protected]>
* @link https://enisinanal.com
* @copyright 2013-2019 Eni Sinanaj
*
@enisinanaj
enisinanaj / default.vcl
Created December 8, 2019 17:02
Full Varnish Cache configuration
#
# This is an example VCL file for Varnish.
#
# It does not do anything by default, delegating control to the
# builtin VCL. The builtin VCL is called when there is no explicit
# return statement.
#
# See the VCL chapters in the Users Guide at https://www.varnish-cache.org/docs/
# and https://www.varnish-cache.org/trac/wiki/VCLExamples for more examples.
@enisinanaj
enisinanaj / default.vcl
Created December 8, 2019 16:45
Basic Varnish-Cache 4 configuration
#
# This is an example VCL file for Varnish.
#
# It does not do anything by default, delegating control to the
# builtin VCL. The builtin VCL is called when there is no explicit
# return statement.
#
# See the VCL chapters in the Users Guide at https://www.varnish-cache.org/docs/
# and https://www.varnish-cache.org/trac/wiki/VCLExamples for more examples.
@enisinanaj
enisinanaj / getRealPath(Context: context, uri: Uri)
Created May 9, 2019 22:30
Get real path from android content uri
public static String getRealFilePath(final Context context, final Uri uri) {
if (null == uri) return null;
final String scheme = uri.getScheme();
String data = null;
if (scheme == null)
data = uri.getPath();
else if (ContentResolver.SCHEME_FILE.equals(scheme)) {
data = uri.getPath();
} else if (ContentResolver.SCHEME_CONTENT.equals(scheme)) {
final Cursor cursor = context.getContentResolver().query(uri, new String[]{MediaStore.Images.ImageColumns.DATA}, null, null, null);
@enisinanaj
enisinanaj / GetChunkFromFile.java
Created April 23, 2019 14:58
Read a chunk of data from the file. Java
public byte[] getNextFileChunk() throws IOException {
FileInputStream fileReader = new FileInputStream(file);
byte[] b;
int realLength = CHUNK_SIZE;
// assuming chunk index starts from 1
if (currentChunk - 1 == chunksLength) {
b = new byte[lastChunkSize];
realLength = lastChunkSize;
@enisinanaj
enisinanaj / BackgroundTransferSample.swift
Created April 4, 2019 14:48 — forked from toddhopkinson/BackgroundTransferSample.swift
Upload Very Large Files In Background on iOS - Alamofire.upload multipart in background
// You have a very very large video file you need to upload to a server while your app is backgrounded.
// Solve by using URLSession background functionality. I will here use Alamofire to enable multipart upload.
class Networking {
static let sharedInstance = Networking()
public var sessionManager: Alamofire.SessionManager // most of your web service clients will call through sessionManager
public var backgroundSessionManager: Alamofire.SessionManager // your web services you intend to keep running when the system backgrounds your app will use this
private init() {
self.sessionManager = Alamofire.SessionManager(configuration: URLSessionConfiguration.default)
self.backgroundSessionManager = Alamofire.SessionManager(configuration: URLSessionConfiguration.background(withIdentifier: "com.lava.app.backgroundtransfer"))
@enisinanaj
enisinanaj / API.md
Created March 4, 2016 14:09 — forked from iros/API.md
Documenting your REST API

Title

<Additional information about your API call. Try to use verbs that match both request type (fetching vs modifying) and plurality (one vs multiple).>

  • URL

    <The URL Structure (path only, no root url)>

  • Method: