Skip to content

Instantly share code, notes, and snippets.

View theSuiGenerisAakash's full-sized avatar
🎄
Holiday mood

Aakash Verma theSuiGenerisAakash

🎄
Holiday mood
View GitHub Profile
@theSuiGenerisAakash
theSuiGenerisAakash / em_cross_en.sql
Last active February 12, 2020 03:44
Perform any DML/DDL operations on selective tables, selective columns and a mix of those
-- A simple script that allows you to perform update and delete operations with optional where clause but mainly giving
-- you the flexibilty of doing so across multiple db, tables and columns
do $$
declare
selectrow record;
begin
for selectrow in
select
'DELETE FROM '|| t.mytable || ' WHERE ' || t.mytable ||'.sampledate > ''12-31-2018''' as script
@theSuiGenerisAakash
theSuiGenerisAakash / split_string.sql
Last active January 23, 2019 06:14
A UDF to split strings based on a delimiter in MySQL
-- Select your database
USE sample_database;
/* You might need to run this if MySQL says that the below function is non-determininstic (although I've added DETERMINSTIC keyword in it) */
-- SET GLOBAL log_bin_trust_function_creators = 1;
DELIMITER $$
DROP FUNCTION IF EXISTS splitString $$
-- Function splitString that returns a substring based on a certain delimiter's position
CREATE FUNCTION splitString (
x VARCHAR(255),
delim VARCHAR(12),
@zcaceres
zcaceres / Include-in-Sequelize.md
Last active July 27, 2024 13:21
using Include in sequelize

'Include' in Sequelize: The One Confusing Query That You Should Memorize

When querying your database in Sequelize, you'll often want data associated with a particular model which isn't in the model's table directly. This data is usually typically associated through join tables (e.g. a 'hasMany' or 'belongsToMany' association), or a foreign key (e.g. a 'hasOne' or 'belongsTo' association).

When you query, you'll receive just the rows you've looked for. With eager loading, you'll also get any associated data. For some reason, I can never remember the proper way to do eager loading when writing my Sequelize queries. I've seen others struggle with the same thing.

Eager loading is confusing because the 'include' that is uses has unfamiliar fields is set in an array rather than just an object.

So let's go through the one query that's worth memorizing to handle your eager loading.

The Basic Query

@wnghdcjfe
wnghdcjfe / index.html
Last active December 15, 2018 05:15
D3 v4 | plot and line chart with tooltip
<!DOCTYPE html>
<meta charset="utf-8">
<style>
/* set the CSS */
.line {
fill: none;
/*stroke: #aaa;
stroke: #43484c;
@markerikson
markerikson / dispatching-action-creators.js
Last active June 28, 2024 05:29
Dispatching action creators comparison
// approach 1: define action object in the component
this.props.dispatch({
type : "EDIT_ITEM_ATTRIBUTES",
payload : {
item : {itemID, itemType},
newAttributes : newValue,
}
});
// approach 2: use an action creator function
@JamesMGreene
JamesMGreene / gitflow-breakdown.md
Last active September 30, 2024 10:04
`git flow` vs. `git`: A comparison of using `git flow` commands versus raw `git` commands.

Initialize

gitflow git
git flow init git init
  git commit --allow-empty -m "Initial commit"
  git checkout -b develop master

Connect to the remote repository