Skip to content

Instantly share code, notes, and snippets.

Avatar
💭
I may be slow to respond.

Ritwick Dey ritwickdey

💭
I may be slow to respond.
View GitHub Profile
View confusing-this.js
function fun1() {
setTimeout(function () { //normal
console.log("normal (setTimeOut)", this);
}, 0);
}
function fun2() {
setTimeout(() => { //arrow
console.log("arrow (setTimeOut)", this);
}, 0);
@ritwickdey
ritwickdey / AppletDemo.java
Last active Nov 25, 2017
Everything in one place - Applet Life Cycle, Parameter Passing ,Drawing, ButtonEvent, MouseEvent & DialogBox
View AppletDemo.java
import java.applet.Applet;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
/*
<applet code="AppletDemo" width="320" height="320">
<param name="myName" value="ritwick dey"/>
</applet>
*/
@ritwickdey
ritwickdey / Sorts.c
Last active Nov 29, 2017
Few Sorts in one place : Bubble Sort, Selection Sort, Insertion Sort, Marge Sort, Quick Sort, Heap Sort
View Sorts.c
/*
---------------------
Bubble Sort,
Selection Sort,
Insertion Sort,
Marge Sort,
Quick Sort,
Heap Sort
----------------------
*/
@ritwickdey
ritwickdey / JobScheduling.c
Created Nov 28, 2017
JobScheduling Algorithm (Greedy Approach) implemented with C
View JobScheduling.c
#include <stdio.h>
#include <stdlib.h>
typedef struct job
{
int id;
int deadLine;
float profit;
int isPossible;
} job;
@ritwickdey
ritwickdey / Fractional_Knapsack.c
Created Nov 28, 2017
Fractional Knapsack (Greedy Approach) is implemented with C language
View Fractional_Knapsack.c
#include <stdio.h>
#include <stdlib.h>
typedef struct Item
{
int itemId;
int weight;
int profit;
float pByw; // profit/weight
float xi;
@ritwickdey
ritwickdey / gist:72c3e68a2366b57188a50b1a552c4190
Created Dec 21, 2017 — forked from rxaviers/gist:7360908
Complete list of github markdown emoji markup
View gist:72c3e68a2366b57188a50b1a552c4190

People

:bowtie: :bowtie: 😄 :smile: 😆 :laughing:
😊 :blush: 😃 :smiley: ☺️ :relaxed:
😏 :smirk: 😍 :heart_eyes: 😘 :kissing_heart:
😚 :kissing_closed_eyes: 😳 :flushed: 😌 :relieved:
😆 :satisfied: 😁 :grin: 😉 :wink:
😜 :stuck_out_tongue_winking_eye: 😝 :stuck_out_tongue_closed_eyes: 😀 :grinning:
😗 :kissing: 😙 :kissing_smiling_eyes: 😛 :stuck_out_tongue:
@ritwickdey
ritwickdey / ExampleOfDependencyInjection.cs
Last active Jan 10, 2018
Example Of Dependency Injection in C#. (BTW, I'm not 100% sure :p )
View ExampleOfDependencyInjection.cs
namespace SomeNamespace
{
public interface ITest
{
void hello();
}
//NO Singleton Class, Simple One.
public class Test1 : ITest
{
@ritwickdey
ritwickdey / face-detection-chrome-api.js
Last active Oct 18, 2019
Face Detection using Google Chrome API (Experimental)
View face-detection-chrome-api.js
const detectFace = () => {
if(!window.FaceDetector) return console.log('Unsupported Version or Feature is not enabled')
const img = document.querySelector('#targetImg');
const faceDetector = new FaceDetector();
const scale = img.width / img.naturalWidth;
faceDetector
.detect(img)
.then(faces =>
faces.map(face => face.boundingBox)
)
@ritwickdey
ritwickdey / GetRandomColorWithRandomOpacity.js
Last active Aug 6, 2018
Get Random Color with Random Opacity (Useful for Charts)
View GetRandomColorWithRandomOpacity.js
const hexColors = [
'#3366CC',
'#DC3912',
'#FF9900',
'#109618',
'#990099',
'#3B3EAC',
'#0099C6',
'#DD4477',
'#66AA00',
View .vscode.json
{
"eslint.autoFixOnSave": true,
"workbench.iconTheme": "material-icon-theme",
"workbench.colorTheme": "One Dark Pro",
"editor.fontSize": 14,
"window.zoomLevel": 0,
"editor.tokenColorCustomizations": {
"textMateRules": [
{
"scope": [