Skip to content

Instantly share code, notes, and snippets.

View chaudharykiran's full-sized avatar

Kiran Kumar Chaudhary chaudharykiran

View GitHub Profile
@apal21
apal21 / ES5 class.js
Last active March 7, 2023 08:06
Example for blog to show the difference between ES5 and ES6 javascript classes using inheritance and prototypes use cases.
'use strict';
/**
* Person class.
*
* @constructor
* @param {String} name - name of a person.
* @param {Number} age - age of a person.
* @param {String} gender - gender of a person.
*/
@brigand
brigand / nickname.md
Created March 9, 2016 07:45
Freenode Setting Up Your Nickname

What is the recommended way to set up my IRC nickname?

Please follow these steps to set up your nick and configure your client. Check off each step to make sure it's been done:

Select a permanent, master nickname. If the nickname you want is registered but has expired, just ask a staffer and in most cases, we will be happy to drop it for you.

Please avoid using the name of a community project or trademarked entity, to avoid conflicts. Write down your password and be sure to keep the sheet of paper in a safe place.

Register your IRC nick:

@manuelbieh
manuelbieh / sequelize-schema-file-generator.js
Last active January 16, 2024 19:25
Automatically generates migration files from your sequelize models
import * as models from "models";
import Sequelize from "sequelize";
import fs from "fs";
delete models.default;
const sequelize = new Sequelize(
'',
'',
'', {
@madhums
madhums / base64-image-upload.js
Created September 14, 2014 17:37
save base64 encoded image
/*
* Taken from http://stackoverflow.com/questions/5867534/how-to-save-canvas-data-to-file/5971674#5971674
*/
var fs = require('fs');
// string generated by canvas.toDataURL()
var img = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAUCAYAAACNiR0"
+ "NAAAAKElEQVQ4jWNgYGD4Twzu6FhFFGYYNXDUwGFpIAk2E4dHDRw1cDgaCAASFOffhEIO"
+ "3gAAAABJRU5ErkJggg==";
// strip off the data: url prefix to get just the base64-encoded bytes
@matheusoliveira
matheusoliveira / json_manipulator.sql
Last active February 17, 2024 15:14
Simple PostgreSQL functions to manipulate json objects. (Note: performance is not a concern for those functions)
CREATE OR REPLACE FUNCTION public.json_append(data json, insert_data json)
RETURNS json
IMMUTABLE
LANGUAGE sql
AS $$
SELECT ('{'||string_agg(to_json(key)||':'||value, ',')||'}')::json
FROM (
SELECT * FROM json_each(data)
UNION ALL
SELECT * FROM json_each(insert_data)