Skip to content

Instantly share code, notes, and snippets.

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

Chalist chalist

🏠
Working from home
View GitHub Profile
@fworks
fworks / install-zsh-windows-git-bash.md
Last active April 19, 2024 19:52
Zsh / Oh-my-zsh on Windows Git Bash
@burnpiro
burnpiro / functionOptimisation.md
Created August 1, 2019 13:14
Spread VS JSON.parse performance in function optimisation

Spread vs JSON.parse speed when calling simple function

const N = 100000;

function test(obj) {
  var result = obj.a + obj.b;
  return result;
}
function test2(obj) {
 var result = obj.a + obj.b;
@rsippl
rsippl / disable_vim_auto_visual_on_mouse.txt
Last active August 20, 2019 09:19 — forked from u0d7i/disable_vim_auto_visual_on_mouse.txt
Disable vim automatic visual mode on mouse select
Add to ~/.vimrc:
set mouse-=a
Then uncomment these lines in /etc/vim/vimrc:
let g:skip_defaults_vim = 1
syntax on
@unicornist
unicornist / Native Date and Number Formatting.js
Last active July 27, 2023 15:46
Natively Format Javascript Dates & Numbers in different Locales (Including Persian Calendar)
(12345.6789).toLocaleString("fa-IR"); // ۱۲٬۳۴۵٫۶۷۹
var now = new Date();
now.toLocaleString(); // 1/27/2018, 12:07:03 AM
now.toLocaleDateString(); // 1/27/2018
now.toLocaleTimeString(); // 12:07:03 AM
now.toLocaleString("fa-IR") // ۱۳۹۶/۱۱/۷،‏ ۰:۰۷:۰۳
now.toLocaleDateString("fa-IR") // ۱۳۹۶/۱۱/۷
@brizandrew
brizandrew / README.md
Created July 28, 2017 22:07
How to use node.js build routines and npm packages in Django.

Using Node.js With Django

When writing django apps it's easy to ignore the organization of your front end code. Often, these backend coders will just write a static js and css file, stick it in the static directory, and call it a day.

You can also build them as two completely independent parts. With a complex gulp build routine independent of the django app. But if you don't know gulp, node, or those kinds of systems it can be a daunting process to get started with.

Enter django-compressor-toolkit (the name doesn't quite roll off the tongue).

Setting Up Django-Compressor-Toolkit

Using django-compressor and django-compressor-toolkit you can write Javascript ES6 code with all its fancy import/export logic or style your pages with sass instead of css, and leave your deploy routine largely untouched.

@oisobstudio
oisobstudio / part.md
Last active April 1, 2023 18:53
Django Pagination Server-Side Menggunakan DataTable

myapp/views.py

import json

from django.views.generic import View
from django.http import HttpResponse
from django.core.paginator import Paginator, EmptyPage, PageNotAnInteger
from django.db.models import Q
from django.core.serializers.json import DjangoJSONEncoder
@leymannx
leymannx / gulpfile.js
Last active July 13, 2023 15:29
Gulp Sass with autoprefixer and minify.
var gulp = require('gulp'),
sass = require('gulp-sass'),
rename = require('gulp-rename'),
cssmin = require('gulp-cssnano'),
prefix = require('gulp-autoprefixer'),
plumber = require('gulp-plumber'),
notify = require('gulp-notify'),
sassLint = require('gulp-sass-lint'),
sourcemaps = require('gulp-sourcemaps');
// Temporary solution until gulp 4
@u0d7i
u0d7i / disable_vim_auto_visual_on_mouse.txt
Last active February 27, 2024 14:08
Disable vim automatic visual mode on mouse select
Disable vim automatic visual mode on mouse select
issue: :set mouse-=a
add to ~/.vimrc: set mouse-=a
my ~/.vimrc for preserving global defaults and only changing one option:
source $VIMRUNTIME/defaults.vim
set mouse-=a
@kloon
kloon / functions.php
Created March 28, 2014 08:58
WooCommerce 2.1 Add confirm password field on My Account register form
<?php
// Add the code below to your theme's functions.php file to add a confirm password field on the register form under My Accounts.
add_filter('woocommerce_registration_errors', 'registration_errors_validation', 10,3);
function registration_errors_validation($reg_errors, $sanitized_user_login, $user_email) {
global $woocommerce;
extract( $_POST );
if ( strcmp( $password, $password2 ) !== 0 ) {
return new WP_Error( 'registration-error', __( 'Passwords do not match.', 'woocommerce' ) );
}
@simonista
simonista / .vimrc
Last active April 25, 2024 02:53
A basic .vimrc file that will serve as a good template on which to build.
" Don't try to be vi compatible
set nocompatible
" Helps force plugins to load correctly when it is turned back on below
filetype off
" TODO: Load plugins here (pathogen or vundle)
" Turn on syntax highlighting
syntax on