Skip to content

Instantly share code, notes, and snippets.

View valentincognito's full-sized avatar
💤

Valentin valentincognito

💤
View GitHub Profile
cloneSkinnedMesh(){
const skinnedMeshes = {}
this.original.traverse( child => {
if(child.isSkinnedMesh){
skinnedMeshes[child.name] = child
}
})
const cloneBones = {}
const cloneSkinnedMeshes = {}
$('#my_form').submit(function(e) {
let validations = [
{
description: 'empty field',
status: $('.field').val().length != 0 ? true : false,
message: 'field xxx is empty'
}
]
let isFormValidated = true
//snippet to easily include three.js shader chunks in your custom shaders
replaceThreeChunkFn(a, b) {
return THREE.ShaderChunk[b] + '\n'
}
shaderParse(glsl) {
return glsl.replace(/\/\/\s?chunk\(\s?(\w+)\s?\);/g, this.replaceThreeChunkFn)
}
//only letters and numbers (no korean, no special chars)
$('.username').on('keyup', function(e){
let val = $(this).val()
val = val.replace(/[^a-zA-Z0-9]/ig, '')
this.value = val
})

Blocking back button on browser (chrome tested)

history.pushState(null, document.title, location.href); 
history.back(); 
history.forward(); 
window.onpopstate = function () { 
  history.go(1); 
};
# Your snippets
#
# Atom snippets allow you to enter a simple prefix in the editor and hit tab to
# expand the prefix into a larger code block with templated values.
#
# You can create a new snippet in this file by typing "snip" and then hitting
# tab.
#
# An example CoffeeScript snippet to expand log to console.log:
#

Dump

mongodump --username user --password "pwd" --db dbName --out /backups/`date "+%Y-%m-%d"`

Restore

mongorestore --username admin --password "pwd" --authenticationDatabase admin dumpFolder/

Add mongodb to your path

Default location: C:\Program Files\MongoDB\Server\4.0\bin

Create a superadmin

mongo
use admin
db.createUser(
 {
@valentincognito
valentincognito / grant_revoke.md
Last active August 16, 2018 10:04
List of useful commands and tips for the android debug bridge

App permissions

//list all packages
adb shell pm list packages

//list all android permissions
adb shell pm list permissions -d -g
@valentincognito
valentincognito / img_rotation.java
Last active July 26, 2018 03:07
Fix the stupid SAMSUNG rotation of picture taken with the camera
File imgFile = new File(image_path); //INTERNAL STORAGE path
if(imgFile.exists()){
Bitmap myBitmap = BitmapFactory.decodeFile(imgFile.getAbsolutePath());
Uri internal = Uri.fromFile(imgFile);
try{
Bitmap img = rotateImageIfRequired(myBitmap, internal);
}catch (IOException e) {
e.printStackTrace();
}