Skip to content

Instantly share code, notes, and snippets.

View Nilzor's full-sized avatar

Frode Nilsen Nilzor

  • Forse.no
  • Oslo, Norway
View GitHub Profile
@Nilzor
Nilzor / bash.rc
Last active August 11, 2017 06:20
bash.rc for Android screenshot and recording
And-Screenshot() {
# Todo: Add demo mode: https://android.googlesource.com/platform/frameworks/base/+/master/packages/SystemUI/docs/demo_mode.md
if [ "$1" = "" ] ; then echo "Specify output file name"
else
adb shell screencap -p /sdcard/screen.png
adb pull /sdcard/screen.png
adb shell rm /sdcard/screen.png
PCT=$2
if [ "$PCT" = "" ]; then PCT=33%; fi
convert screen.png -resize $PCT $1
@Nilzor
Nilzor / php-intellij-xdebug-linux.md
Created October 19, 2016 18:59
PHP debugging intellij linux apache2
  • sudo apt-get install php5-xdebug
  • "PHP Web Application" run configuration backed by a "PHP Server" with XDebug set up. Run in debug mode.
  • This at the end of /etc/php5/apache2/php.in
[xdebug]
zend_extension="/usr/lib/php5/20121212/xdebug.so"
xdebug.remote_enable=1
xdebug.remote_handler=dbgp
xdebug.remote_mode=req
@Nilzor
Nilzor / fail.sh
Last active August 22, 2016 07:39
AppNexus Curl scripts
curl -I 'http://ams1-ib.adnxs.com/click?yhyNPW26GkDKHI09bboaQAAAAOBRuBNAyhyNPW26GkDKHI09bboaQMsSLcutjYE0CBHfEVlphz_VV7VXAAAAAOSzYgDgDAAA4AwAAAIAAAACeQQDBR8OAAAAAABVU0QATk9LAEAB-gBhdQAAAAABAQQAAQAAAKoAqyBnfwAAAAA./cnd=%210QjpZQiioNAGEILykRgYhb44IAQoioTQugw./bn=63379/referrer=http%3A%2F%2Fwww.vg.no%2Fsport%2Fol-2016%2Fslik-var-ol-natten-hekke-isabelle-lei-trusespoersmaal%2Fa%2F23768893%2F/clickenc=https://track.adform.net/C/?bn=13442192;adfibeg=0;cdata=BrHTQUfSbdPfs5ZCfJ32id3uF0FxvvzX9DxWEU-biQUlI0uGMmq9cwXtoBuHWFajy0ZLabVcrmPXHUiMkqf858rncRr8QBzgw3iI60gHGBc1;;CREFURL=http%3a%2f%2fwww.vg.no%2fsport%2fol-2016%2fslik-var-ol-natten-hekke-isabelle-lei-trusespoersmaal%2fa%2f23768893%2f;C=1' -H 'Accept-Encoding: gzip, deflate, sdch' -H 'Accept-Language: en-GB,en-US;q=0.8,en;q=0.6' -H 'Upgrade-Insecure-Requests: 1' -H 'User-Agent: Mozilla/5.0 (Linux; Android 6.0; Nexus 5 Build/MRA58N) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/52.0.2743.98 Mobile Safari/537.36' -H 'Accept: text/html,application/xhtml+xml,applicatio
@Nilzor
Nilzor / AsyncPatterns.cs
Created June 24, 2016 14:15
Asynchronouse patterns in C#
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AsyncPatterns
{
class Program
{
@Nilzor
Nilzor / mobile-page-template.html
Created June 16, 2016 08:03
Shell of a mobile web page with a minimum of meta tags
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
</head>
<body>
</body>
</html>
@Nilzor
Nilzor / AutoNamingReducer.js
Last active May 5, 2016 16:06
A base class for reducers. Allows generating Redux Actions for functions by introspecting and naming the action from the class and function name.
/**
* A base class for generating Redux Actions for functions
* by introspecting and naming the action after the class and function name
*/
export class AutoNamingReducer {
/** Generates and returns a Redux Action for the specified function. Function must reside in a class
* extending AutoNamingReducer
* @param func {function} A function reference
* @param params {object} An optional parameter object which will be spliced with the action object and passed
@Nilzor
Nilzor / RetrofitIonClient.java
Last active February 15, 2016 11:35
A Retrofit 1.x HTTP Client using Ion and its AndroidAsync library.
/*
* This class is an adapter for Retrofit allowing you to use ion/andorid-async with Retrofix 1.x.
* Since retrofit is inherently synchronous under the hood, adding this adapter unfortunately does not
* yield a smaller thread footprint. -Notice the .get() blocking call in the code below.
* So why would you use this? My use case is that we rely on third party libraries that requre Retrofit.
* To get all our HTTP comms to go through the same logic we use this adapter.
* That gives us zero dependencies to apache-http-client or okhttp.
*
* ion home: https://github.com/koush/ion
*/
@Nilzor
Nilzor / TwoWayBoundString.java
Created January 31, 2016 10:25
Tow-way data bound string, based on Blog by Fabio Colini
import android.databinding.BaseObservable;
import android.databinding.BindingAdapter;
import android.databinding.BindingConversion;
import android.text.Editable;
import android.text.TextWatcher;
import android.widget.EditText;
import java.io.Serializable;
@Nilzor
Nilzor / RuntimeTypeAdapterFactory.java
Created January 12, 2016 11:47
RuntimeTypeAdapterFactory for named type serialization through Gson
/*
* Copyright (C) 2011 Google Inc.
*
* 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
@Nilzor
Nilzor / And-Record.ps1
Created January 5, 2016 12:08
Android screenshot and video grab helper script for PowerShell
<#
.SYNOPSIS
Records a video to a temp file on the device then downloads to local system and deletes temp file.
.PARAMETER DestFile
Destination path and file on local file system
.NOTES
Author : Frode Nilsen <nilzor@gmail.com>
.EXAMPLE
And-Record c:\temp\video.mp4
.LINK #>