Skip to content

Instantly share code, notes, and snippets.

View xyznaveen's full-sized avatar
🎯
Focusing

Naveen Niraula xyznaveen

🎯
Focusing
View GitHub Profile
country=GB
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
network={
ssid="wifi name"
psk="your weird password"
}
@xyznaveen
xyznaveen / enable MOD_REWRITE.txt
Last active February 9, 2019 08:16
Gist to change the default root of apache2 and enable mod_rewrite.
-------------------------------------------------
ADDING CUSTOM PATH AS ROOT DIRECTORY FOR APACHE
-------------------------------------------------
1. Go to apahce's configuration directory
cd /etc/apache2/sites-available
2. Open the configuration file with your favorite editor.
private void showOpenWith(File file) {
if (getContext() == null) {
return;
}
String extension = getFileExtension(file);
Uri uri = null;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
@xyznaveen
xyznaveen / MyAwesomeFragment.java
Last active October 18, 2018 13:21
Android EditText and TextInputLayoutValidation snippet.
public class RegisterFragment extends BaseFragment
implements View.OnClickListener {
@Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
// Simple Implementation Example
List<TextInputLayout> inputLayoutList = new ArrayList<>();
inputLayoutList.add(fullName);
@xyznaveen
xyznaveen / generate-pushid.js
Created July 18, 2018 09:17 — forked from mikelehen/generate-pushid.js
JavaScript code for generating Firebase Push IDs
/**
* Fancy ID generator that creates 20-character string identifiers with the following properties:
*
* 1. They're based on timestamp so that they sort *after* any existing ids.
* 2. They contain 72-bits of random data after the timestamp so that IDs won't collide with other clients' IDs.
* 3. They sort *lexicographically* (so the timestamp is converted to characters that will sort properly).
* 4. They're monotonically increasing. Even if you generate more than one in the same timestamp, the
* latter ones will sort after the former ones. We do this by using the previous random bits
* but "incrementing" them by 1 (only in the case of a timestamp collision).
*/
Generate Private / Public key in ~/.ssh/ folder
ssh-keygen -t rsa
Copy the resulting public key to the ~/.ssh/known_hosts folder on the server
cat ~/.ssh/id_rsa.pub | ssh username@hostname 'cat >> .ssh/authorized_keys'
ENJOY!! :D
@xyznaveen
xyznaveen / .htaccess
Last active June 22, 2018 14:52
.htaccess file to force www, htttps and redirect all requests to index.php
Options +FollowSymLinks
RewriteEngine On
RewriteBase /
# Redirect all requests to index.php only if it is not a directory or file
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.+)$ index.php/$1 [L]
RewriteCond %{HTTPS} off
@xyznaveen
xyznaveen / git-deployment.md
Created May 16, 2018 07:37 — forked from noelboss/git-deployment.md
Simple automated GIT Deployment using Hooks

Simple automated GIT Deployment using GIT Hooks

Here are the simple steps needed to create a deployment from your lokal GIT repository to a server based on this in-depth tutorial.

How it works

You are developing in a working-copy on your local machine, lets say on the master branch. Most of the time, people would push code to a remote server like github.com or gitlab.com and pull or export it to a production server. Or you use a service like my Deepl.io to act upon a Web-Hook that's triggered that service.

@xyznaveen
xyznaveen / DesierdActivity.java
Created February 8, 2018 16:17
Simple File Chooser
//...ignoring other code.../
/*Call this method whenever you want to show the file chooser*/
/**
* Tweak method from website*/
private void processFile(){
FileChooser fileChooser = new FileChooser(MainActivity.this);
fileChooser.setFileListener(new FileChooser.FileSelectedListener() {