Skip to content

Instantly share code, notes, and snippets.

# update the Apt cache and upgrade the current packages of system
sudo apt update && sudo apt upgrade
# nstall few dependencies required
sudo apt install software-properties-common ca-certificates lsb-release apt-transport-https
# Add the Ondrej PPA
LC_ALL=C.UTF-8 add-apt-repository ppa:ondrej/php
@wajahatkarim3
wajahatkarim3 / ActivitiesLaunchingWay.kt
Last active April 3, 2023 08:12
Kotlin Extensions for simpler, easier and funw way of launching of Activities
/**
* Kotlin Extensions for simpler, easier and funw way
* of launching of Activities
*/
inline fun <reified T : Any> Activity.launchActivity (
requestCode: Int = -1,
options: Bundle? = null,
noinline init: Intent.() -> Unit = {})
{
import android.arch.lifecycle.ViewModel
import android.os.Looper
import android.support.annotation.CallSuper
import com.google.errorprone.annotations.CheckReturnValue
import com.uber.autodispose.CompletableSubscribeProxy
import com.uber.autodispose.FlowableSubscribeProxy
import com.uber.autodispose.LifecycleNotStartedException
import com.uber.autodispose.MaybeSubscribeProxy
import com.uber.autodispose.ObservableSubscribeProxy
@mahmudahsan
mahmudahsan / ios_detect.swift
Last active July 9, 2021 09:07
iPhone X and other iOS device detection by Swift and Objective-C
struct Device {
// iDevice detection code
static let IS_IPAD = UIDevice.current.userInterfaceIdiom == .pad
static let IS_IPHONE = UIDevice.current.userInterfaceIdiom == .phone
static let IS_RETINA = UIScreen.main.scale >= 2.0
static let SCREEN_WIDTH = Int(UIScreen.main.bounds.size.width)
static let SCREEN_HEIGHT = Int(UIScreen.main.bounds.size.height)
static let SCREEN_MAX_LENGTH = Int( max(SCREEN_WIDTH, SCREEN_HEIGHT) )
static let SCREEN_MIN_LENGTH = Int( min(SCREEN_WIDTH, SCREEN_HEIGHT) )
@javilobo8
javilobo8 / download-file.js
Last active October 27, 2024 09:15
Download files with AJAX (axios)
axios({
url: 'http://localhost:5000/static/example.pdf',
method: 'GET',
responseType: 'blob', // important
}).then((response) => {
const url = window.URL.createObjectURL(new Blob([response.data]));
const link = document.createElement('a');
link.href = url;
link.setAttribute('download', 'file.pdf');
document.body.appendChild(link);
@craigvantonder
craigvantonder / flush-dns.sh
Last active February 3, 2021 04:42
Flushing the DNS in Ubuntu 16.04
#!/bin/bash
# NB: First install nscd with sudo apt-get install nscd
# run this command to flush dns cache:
sudo /etc/init.d/dns-clean restart
# or use:
sudo /etc/init.d/networking force-reload
# Flush nscd dns cache:
sudo /etc/init.d/nscd restart
@idecardo
idecardo / homestead-manual-install.md
Last active November 16, 2023 08:34
Laravel Homestead Manual Installation

Getting Started

Laravel Homestead is an official, pre-packaged Vagrant box that provides you a wonderful development environment without requiring you to install PHP, HHVM, a web server, and any other server software on your local machine. Read more...

Download

Download homestead box:

@jiangecho
jiangecho / SplashActivity.java
Created April 29, 2016 03:42
simulate user clicks on the content of webview
int X_MAX = 412;
int Y_MAX = 50;
int x, y;
x = random.nextInt(X_MAX);
y = random.nextInt(Y_MAX);
// String htmlEventJs = "var ev = document.createEvent(\"HTMLEvents\"); " +
// "var el = document.elementFromPoint(%d,%d); " +
// "ev.initEvent('click',true,true);" +
// " el.dispatchEvent(ev);";
@niksumeiko
niksumeiko / disable-html-form-input-autocomplete-autofill.md
Last active November 17, 2024 18:00
Disable HTML form input autocomplete and autofill

Disable HTML Form Input Autocomplete and Autofill

  1. Add autocomplete="off" onto <form> element;
  2. Add hidden <input> with autocomplete="false" as a first children element of the form.
<form autocomplete="off" method="post" action="">
    <input autocomplete="false" name="hidden" type="text" style="display:none;">
    ...
@sgr-ksmt
sgr-ksmt / UIView+NibInstantiatable.swift
Last active October 20, 2021 13:33
Load ViewController from Storyboard or View from Xib (These are same name.) Require : Swift 2.0
protocol NibInstantiatable {
static var NibName: String { get }
}
extension NibInstantiatable {
static var NibName: String { return String(Self) }
static func instantiate() -> Self {
return instantiateWithName(NibName)