Skip to content

Instantly share code, notes, and snippets.

View krshubham's full-sized avatar
🎯
Focusing

Kumar Shubham krshubham

🎯
Focusing
View GitHub Profile
@calmhandtitan
calmhandtitan / BIT1.c
Created December 9, 2013 20:29
Point Update, Range Sum Query Binary Indexed Tree
//Point Update, Range Sum Query Binary Indexed Tree
//Author: Chandan Mittal
#include<stdio.h>
int BIT[100010], n, a[100010];
void update(int x, int v)
{
while(x <= n)
{
// Restify Server CheatSheet.
// More about the API: http://mcavage.me/node-restify/#server-api
// Install restify with npm install restify
// 1.1. Creating a Server.
// http://mcavage.me/node-restify/#Creating-a-Server
var restify = require('restify');
@tagr
tagr / server.js
Created September 28, 2014 20:22
Node.js/Express: Add Expires header to /images and /stylesheets directories
/**
* Module dependencies.
*/
var express = require('express')
, routes = require('./routes')
, user = require('./routes/user')
, http = require('http')
, path = require('path');
@ggtools
ggtools / countContainers.sh
Created November 17, 2014 13:27
A simple script to count the containers on a Docker host.
#!/bin/bash
function countContainers() {
docker ps -q $1 | wc -l
}
function countCrashedContainers() {
docker ps -a | grep -v -F 'Exited (0)' | grep -c -F 'Exited ('
}
@SriramKeerthi
SriramKeerthi / Load.java
Last active September 27, 2022 09:25
Simple CPU Load Generator in Java
package com.caffinc.grex.core;
/**
* SPDX-License-Identifier: MIT
*
* Generates Load on the CPU by keeping it busy for the given load percentage
* @author Sriram
*/
public class Load {
/**
@indiesquidge
indiesquidge / promise-dot-all.js
Last active January 20, 2024 15:03
Recreating Promise.all with async/await
/*
Let us re-create `Promise.all`
`Promise.all` method returns a promise that resolves when all of the promises in the iterable argument have resolved,
or rejects with the reason of the first passed promise that rejects.
Read more about `Promise.all` on MDN: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/all
A basic example would be something like this:

GSoC'17 summary: Third party integrations and extension of some features, Teem

Kumar Shubham | website | twitter | github | email

Introduction

I'd like to first start by thanking my mentor Antonio, who was so friendly that I never felt like I was talking to someone who is senior to me. Whatever I have done wouldn't have been possible without our daily meetings, which were scheduled to be for 5 minutes but often we discussed things for more than 30 minutes! After working this summer I can say that I have got a good knowledge of how things go in a large codebase and how we should contribute in open source projects! I also got to know some quite details about javascript and also got to work with docker!. In short, it was a wonderful experience!

*I also made a presentation that will give you a slight introduction to what things I did du

@atfornes
atfornes / CleanSpacesRebase.sh
Created September 5, 2017 11:57
Git rebase interactive cleaning space only line changes
#!/bin/bash
## Rebases interactive current branch over master (or <branch> provided as first argument) removing whitespace changes
# based on https://stackoverflow.com/a/9784089/4928558 and https://stackoverflow.com/a/23911001/4928558
branch=master
if [[ $1 ]];
then

Strings

String.prototype.*

None of the string methods modify this – they always return fresh strings.

  • charAt(pos: number): string ES1

    Returns the character at index pos, as a string (JavaScript does not have a datatype for characters). str[i] is equivalent to str.charAt(i) and more concise (caveat: may not work on old engines).