Skip to content

Instantly share code, notes, and snippets.

View xyznaveen's full-sized avatar
🎯
Focusing

Naveen Niraula xyznaveen

🎯
Focusing
View GitHub Profile
@ccssmnn
ccssmnn / README.md
Created February 9, 2020 12:43
Raspberry Pi 4 + Theia IDE = ❤️

Set up Theia IDE on Raspberry Pi 4

Requirements

Install node version 10 and yarn:

curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.5/install.sh | bash
nvm install 10
npm install -g yarn
@omurbekjk
omurbekjk / generateRandomGeoLocations.ts
Last active August 7, 2019 09:32 — forked from mkhatib/geo.js
A Typescript utility function to generate number of random Geolocations around a center location and in a defined radius.
export class GeoUtil {
/**
* @param center = {lat, lng}
* @param radius = 1000
* @param count = 10
*/
static generateRandomPoints(center, radius = 1000, count = 10) {
const points = [];
for (let i = 0; i < count; i++) {
points.push(this.generateRandomPoint(center, radius));
@srph
srph / web.php
Created November 2, 2016 00:07
Laravel - Catch all except /api routes. Useful for SPAs inside Laravel.
<?php
Route::get('{all}', function () {
return view('index');
})->where('all', '^((?!api).)*');
@noelboss
noelboss / git-deployment.md
Last active April 1, 2025 16:56
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 local 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 deepl.io to act upon a Web-Hook that's triggered that service.

@petitviolet
petitviolet / MainThreadCallback.java
Last active May 13, 2023 12:15
OkHttp Callback on Main Thread.
public abstract class MainThreadCallback implements Callback {
private static final String TAG = MainThreadCallback.class.getSimpleName();
abstract public void onFail(final Exception error);
abstract public void onSuccess(final String responseBody);
@Override
public void onFailure(final Request request, final IOException e) {
@mikelehen
mikelehen / generate-pushid.js
Created February 11, 2015 17:34
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).
*/
@myusuf3
myusuf3 / delete_git_submodule.md
Created November 3, 2014 17:36
How effectively delete a git submodule.

To remove a submodule you need to:

  • Delete the relevant section from the .gitmodules file.
  • Stage the .gitmodules changes git add .gitmodules
  • Delete the relevant section from .git/config.
  • Run git rm --cached path_to_submodule (no trailing slash).
  • Run rm -rf .git/modules/path_to_submodule (no trailing slash).
  • Commit git commit -m "Removed submodule "
  • Delete the now untracked submodule files rm -rf path_to_submodule
@praseodym
praseodym / AESGCMUpdateAAD2.java
Last active May 13, 2024 10:20
JDK8 AES-GCM code example
import javax.crypto.*;
import javax.crypto.spec.GCMParameterSpec;
import java.nio.ByteBuffer;
import java.security.SecureRandom;
import java.util.Arrays;
public class AESGCMUpdateAAD2 {
// AES-GCM parameters
public static final int AES_KEY_SIZE = 128; // in bits
@amitchhajer
amitchhajer / Count Code lines
Created January 5, 2013 11:08
Count number of code lines in git repository per user
git ls-files -z | xargs -0n1 git blame -w | perl -n -e '/^.*\((.*?)\s*[\d]{4}/; print $1,"\n"' | sort -f | uniq -c | sort -n
@harningt
harningt / SimpleCrypto.java
Created September 22, 2012 19:00
Simple Android Stream Crypto
package us.eharning.android.cryptosample;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.security.GeneralSecurityException;
import java.security.SecureRandom;
import java.security.spec.AlgorithmParameterSpec;
import java.security.spec.KeySpec;