Skip to content

Instantly share code, notes, and snippets.

View shiponcs's full-sized avatar
💻
Coding

Abdul Matin shiponcs

💻
Coding
View GitHub Profile
@zYeoman
zYeoman / compile.sh
Last active May 6, 2022 16:16 — forked from martinsik/index.html
Simple WebSocket server based on libwebsockets. For full description read http://martinsikora.com/libwebsockets-simple-websocket-server
gcc libwebsockets-websocket.c -L/usr/local/lib -lwebsockets
@sbernard31
sbernard31 / test.c
Last active March 11, 2023 18:04
UDP load balancer proto using bcc (XDP/Bpf)
#define KBUILD_MODNAME "foo"
#include <uapi/linux/bpf.h>
#include <linux/bpf.h>
#include <linux/icmp.h>
#include <linux/if_ether.h>
#include <linux/if_vlan.h>
#include <linux/in.h>
#include <linux/ip.h>
#include <linux/tcp.h>
#include <linux/udp.h>
@shiponcs
shiponcs / 1225-I.cpp
Last active May 14, 2020 10:14
Timus DP 1225-Flag
#include <iostream>
using namespace std;
using ull = unsigned long long;
int main()
{
int n;
cin >> n;
ull dp[n + 1][2]; // dp[i][0] i-th stripe ends with white
dp[1][0] = dp[1][1] = dp[2][0] = dp[2][1] = 1;
@shiponcs
shiponcs / createStore.js
Created April 25, 2020 14:00
This is the basic implementation (without a few minor details) of createStore function of Redux library
const createStore = (reducer) => {
let state;
let listeners = [];
const getState = () => state;
const dispatch = (action) => {
state = reducer(state, action);
listeners.forEach((listener) => listener());
};
@shiponcs
shiponcs / ComponentDidUpdate.js
Last active May 6, 2020 14:24
portratis a basic difference between class and functional component of ReactJS, componentDidUpdate in class component and useEffect in functional component can be used to achieve same thing, but there are some big differences not due to how React defines it but how javascript works. Further, we can use 'useRef' hook to persist data in functional…
import React, { useState, useEffect } from "react";
class Counter extends React.Component {
state = {
count: 0,
};
increment = () => this.setState({ count: this.state.count + 1 });
decrement = () => this.setState({ count: this.state.count - 1 });
reset = () => this.setState({ count: this.state.count });
// line matters
@Gkemon
Gkemon / LinkedList.java
Created July 7, 2021 18:14
LinkedList.java
public class TestLinkedListImplementation {
public static void main(String args[]) {
LinkedList ll = new LinkedList();
ll.addValue(1);
ll.addValue(2);
ll.addValue(3);
ll.addValue(4);
ll.addValue(5);
ll.addValue(6);