Skip to content

Instantly share code, notes, and snippets.

View pishguy's full-sized avatar
✍️
Focusing

Mahdi Pishguy pishguy

✍️
Focusing
View GitHub Profile
@codeswimmer
codeswimmer / Android: AsyncTaskLoader<D> Skeleton
Created March 24, 2011 04:42
Android: AsyncTaskLoader Fragment
public class RetrievedDataFragment extends Fragment implements LoaderManager.LoaderCallbacks<D> {
public RetrievedDataFragment() {
}
@Override
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
getLoaderManager().initLoader(0, null, this);
@moklett
moklett / openconnect.md
Created July 24, 2012 15:21
OpenConnect VPN on Mac OS X

Unfortunately, the Cisco AnyConnect client for Mac conflicts with Pow. And by "conflicts", I mean it causes a grey-screen-of-death kernel panic anytime you connect to the VPN and Pow is installed.

As an alternative, there is OpenConnect, a command-line client for Cisco's AnyConnect SSL VPN.

Here's how to get it set up on Mac OS X:

  1. OpenConnect can be installed via homebrew:

     brew update
    

brew install openconnect

@KevinGaudin
KevinGaudin / report.php
Last active October 17, 2021 07:00
Simplest PHP ACRA backend
<?php
// Outputs all POST parameters to a text file. The file name is the date_time of the report reception
$fileName = date('Y-m-d_H-i-s').'.txt';
$file = fopen($fileName,'w') or die('Could not create report file: ' . $fileName);
foreach($_POST as $key => $value) {
$reportLine = $key." = ".$value."\n";
fwrite($file, $reportLine) or die ('Could not write to report file ' . $reportLine);
}
fclose($file);
?>
@daichan4649
daichan4649 / BackPressedListener.java
Last active February 9, 2018 08:27
Fragment へBACK押下時イベントを通知する (Android)
public interface BackPressedListener {
void onBackPressed();
}
@skyfishjy
skyfishjy / CursorRecyclerViewAdapter.java
Last active December 16, 2023 08:55
CursorRecyclerViewAdapter
/*
* Copyright (C) 2014 skyfish.jy@gmail.com
*
* 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
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
var mediaJSON = { "categories" : [ { "name" : "Movies",
"videos" : [
{ "description" : "Big Buck Bunny tells the story of a giant rabbit with a heart bigger than himself. When one sunny day three rodents rudely harass him, something snaps... and the rabbit ain't no bunny anymore! In the typical cartoon tradition he prepares the nasty rodents a comical revenge.\n\nLicensed under the Creative Commons Attribution license\nhttp://www.bigbuckbunny.org",
"sources" : [ "http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/BigBuckBunny.mp4" ],
"subtitle" : "By Blender Foundation",
"thumb" : "images/BigBuckBunny.jpg",
"title" : "Big Buck Bunny"
},
{ "description" : "The first Blender Open Movie from 2006",
"sources" : [ "http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/ElephantsDream.mp4" ],
@alibo
alibo / zip_server.js
Last active January 24, 2023 11:59
Generating & Downloading zip folder on the fly (dynamically) using Node.JS
//@see https://www.npmjs.com/package/archiver
var archiver = require('archiver')
var http = require('http');
http.createServer(function(request, response) {
var archiver = archiver('zip')
archiver.pipe(response)
response.setHeader('Content-type', 'application/zip')
response.setHeader('Content-disposition', 'attachment; filename=file_name.zip');
@cesarferreira
cesarferreira / api.java
Last active February 1, 2022 16:32
RxJava and Retrofit sample
public interface API {
@GET("/user/{username}/dogs")
Observable<Dog> getAllDogsOf(@Path("username") String username);
@GET("/dog/{id}")
Observable<Dog> getDogInfoById(@Path("id") int dogId);
}
@JeffreyWay
JeffreyWay / PjaxMiddleware.php
Last active February 24, 2024 13:40
Laravel middleware for working with pjax.
<?php
namespace App\Http\Middleware;
use Closure;
use Illuminate\Http\Request;
use Illuminate\Http\Response;
use Symfony\Component\DomCrawler\Crawler;
class PjaxMiddleware
@Antarix
Antarix / LagTracker.java
Created October 20, 2015 06:25
A simple class that can track how long code takes to execute.
import android.util.Log;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.TimeUnit;
/**
* @author Aidan Follestad (afollestad)
*/
public class LagTracker {