Skip to content

Instantly share code, notes, and snippets.

View taulutwashi's full-sized avatar
🏠
Working from home

Taulut Hossain Washi taulutwashi

🏠
Working from home
  • Ami Probashi
  • Dhaka,Bangladesh
View GitHub Profile
@taulutwashi
taulutwashi / withPreventDoubleClick.js
Last active July 23, 2018 06:29
React Native- Prevent Double click
import React from 'react';
import debounce from 'lodash.debounce'; // 4.0.8
const withPreventDoubleClick = (WrappedComponent) => {
class PreventDoubleClick extends React.PureComponent {
debouncedOnPress = () => {
this.props.onPress && this.props.onPress();
}
@taulutwashi
taulutwashi / gist:d1e97eca24f76b231dbb98f4370de913
Created August 29, 2018 10:26
laravel parent child in same table
class ProjectTree extends Model {
//each category might have one parent
public function parent() {
return $this->belongsToOne(static::class, 'parent_id');
}
//each category might have multiple children
public function children() {
return $this->hasMany(static::class, 'parent_id')->orderBy('name', 'asc');
}
}
@taulutwashi
taulutwashi / npmerror.md
Last active September 3, 2018 18:13
Error handler for npm

//events.js:183 throw er; // Unhandled 'error' event
rm -rf node_modules && npm cache clean --force && npm install

lsof | wc -l

@taulutwashi
taulutwashi / custom.js
Created September 5, 2018 05:14
jquery code example
/*$.ajaxSetup({
headers: {
'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
}
});*/
var csrf = $('meta[name=csrf-token]').attr('content');
$.ajaxSetup({
beforeSend: function(request) {
@taulutwashi
taulutwashi / mvc.js
Created December 9, 2018 18:58
This is a simple MVC pattern template for jquery
// This Is Controller for contact Model and View
const Controller = {
// Initiate Model and View method
init: function() {
Model.init();
View.init();
},
@taulutwashi
taulutwashi / Readme
Created January 3, 2019 14:54
This is the template for project documentation
$project
========
$project will solve your problem of where to start with documentation,
by providing a basic explanation of how to do it easily.
Look how easy it is to use:
import project
# Get your stuff done
@taulutwashi
taulutwashi / app.js
Created May 3, 2020 05:11
Async and await in js
// Async and Await are extensions of promises
// Await work under async method
function findAsset (page) {
let url = path.join(__dirname,'public',page);
return new Promise((resolve, reject) => {
fs.readFile(url,'utf-8',(err,data) => {
if(err) reject(err)
@taulutwashi
taulutwashi / 1.js
Created February 28, 2021 12:31 — forked from getify/1.js
Converting English number sentences ("one hundred forty two point three") to numeric digits ("142.3")
convert("one hundred five"); // "105"
convert("six hundred and fifty three"); // "653"
convert("zero zero one two three"); // "123"
convert("twelve o three"); // "1203"
convert("thirteen zero nine"); // "1309"
convert("fifteen sixteen"); // "1516"
convert("fourteen ninety two"); // "1492"
convert("nineteen ten"); // "1910"
convert("twelve hundred"); // "1200"
convert("twenty three hundred"); // "2300"