Skip to content

Instantly share code, notes, and snippets.

View khaliqgant's full-sized avatar
💯
👨🏿‍💻

Khaliq khaliqgant

💯
👨🏿‍💻
View GitHub Profile
@khaliqgant
khaliqgant / multile-watch-tasks.md
Last active March 16, 2022 08:51
[Multiple Watch Tasks] Run Multiple watch tasks with one command in new tabs #javascript #cli
  • Use this tab function as an alias
  • Chain two commands together and enclose each command in quotes. Example:
tab "watchify public/assets/js/sick.js -o public/assets/js/app.js -v" && tab "nodemon server.js"
@khaliqgant
khaliqgant / IFFE Quick Example
Last active March 16, 2022 08:54
[IFFE Example] IFFE Function #javascript
var Gallery = (function() {
// whole lotta code here
})();
@khaliqgant
khaliqgant / Slim Listeners, Fat Methods
Last active March 16, 2022 08:54
[Iterate To Create Listeners] Slim Listeners, Fat Methods #jquery
_main.$pushLinks.each(function(){
$(this).on('click', function(e){
_push.clickEvent = true;
var $el = $(this);
_mobile.mobileCheck($el);
_filters.urlAnalyzer('add', $el, false);
return false;
});
});
@khaliqgant
khaliqgant / tab.bash
Last active March 16, 2022 08:53 — forked from bobthecow/tab.bash
[Open Terminal Tab From CLI] Open new Terminal tabs from the command line #cli #bash
#!/bin/bash
#
# Open new Terminal tabs from the command line
#
# Original Author: Justin Hileman (http://justinhileman.com)
# Modified By: Khaliq Gant (http://khaliqgant.com)
# Installation:
# Add the following function to your `.bashrc` or `.bash_profile`,
# or save it somewhere (e.g. `~/.tab.bash`) and source it in `.bashrc` or `.zshrc`
@khaliqgant
khaliqgant / interface.ts
Last active March 16, 2022 08:53
[TS Interfaces in Tests] Using Typescript Interfaces In Tests using JSON schema #typescript #tests
/**
*
* Generate Schema
* @desc dynamically create the JSON Schema
* @see https://github.com/YousefED/typescript-json-schema#programmatic-use
* @return {Object} schema
*
*/
function generateSchema (interfaceType: string): Object {
const program = TJS.getProgramFromFiles([resolve('./interfaces/admin/SchemaResponse.ts')], {strictNullChecks: true});
@khaliqgant
khaliqgant / 1_overlap.js
Last active March 16, 2022 08:52 — forked from mxriverlynn/1_overlap.js
[Date Range Overlap] checking for date range overlap #javascript
// this function takes an array of date ranges in this format:
// [{ start: Date, end: Date}]
// the array is first sorted, and then checked for any overlap
function overlap(dateRanges){
var sortedRanges = dateRanges.sort((previous, current) => {
// get the start date from previous and current
var previousTime = previous.start.getTime();
var currentTime = current.start.getTime();
@khaliqgant
khaliqgant / drop_db.sql
Last active August 3, 2022 20:21
[Postgres Drop Database] Drop live database and create public schema #postgres #database
# with auth
> psql -h 10.000.0.0 -d mydb -U myuser
> psql postgres postgres
drop schema public cascade;
create schema public;
\q and enter to exit
@khaliqgant
khaliqgant / dump.sql
Last active March 16, 2022 09:10
[Postgres Create Dump & Restore] Fast way to create a postgres dump #postgres #database
# dump
pg_dump -h localhost -U postgres -p 5432 -Fc -Z 9 --file=local.dump
# restore
pg_restore -h localhost -U postgres -Fc -j 8 -p 5432 -vvv -d postgres local.dump
# source: https://stackoverflow.com/questions/15692508/a-faster-way-to-copy-a-postgresql-database-or-the-best-way
@khaliqgant
khaliqgant / json.sql
Created March 16, 2022 08:48
[Postgres Dump A Table As JSON] Dump a table in JSON format #postgres #database
\t
\a
\o data.json
select json_agg(t) FROM (SELECT * from schedules_required_shifts) t;
// https://dba.stackexchange.com/questions/90482/export-postgres-table-as-json
@khaliqgant
khaliqgant / like.sql
Created March 16, 2022 08:50
[Postgres Like Query] Text matching using like #postgres #database
username LIKE '%zveer%'
https://www.tutorialspoint.com/postgresql/postgresql_like_clause.htm