Skip to content

Instantly share code, notes, and snippets.

View Buffer0x7cd's full-sized avatar

Manvendra Singh Buffer0x7cd

View GitHub Profile
Starting profile
103902924 function calls (94145786 primitive calls) in 95.641 seconds
Ordered by: cumulative time
ncalls tottime percall cumtime percall filename:lineno(function)
1 0.000 0.000 95.641 95.641 core_v1_api.py:13605(list_pod_for_all_namespaces)
1 0.000 0.000 95.641 95.641 core_v1_api.py:13633(list_pod_for_all_namespaces_with_http_info)
1 0.000 0.000 95.641 95.641 api_client.py:291(call_api)
1 1.028 1.028 95.641 95.641 api_client.py:110(__call_api)
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <errno.h>
pid_t Fork(void)
{
pid_t Fork(void)
{
pid_t pid = fork();
if (pid < 0)
{
perror("Error, while calling fork\n");
exit(EXIT_FAILURE);
}
return pid;
}
FROM node:9.3.0-onbuild
COPY ./ /usr/src/app
RUN npm install
EXPOSE 3000
ENTRYPOINT ["npm"]
CMD ["run", "start"]
''' Create a virtualenv with python3 or run with default os installation (adjust the sheband based on you enviornment)
Install script dependencies with pip (requests, beautifulsoup4, lxml
make the script executable with chmod +x crawler.py
run the script with ./crawler.py
'''
#!/usr/bin/env python3
from bs4 import BeautifulSoup
import requests
#!/bin/bash
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | apt-key add -
add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
apt-get update
apt-get install -y docker-ce
usermod -aG docker ubuntu
{
"name": "ambassador",
"app_id": "7043185f",
"type": "ionic-angular",
"integrations": {
"cordova": {}
}
}
@Buffer0x7cd
Buffer0x7cd / setup_mongo.sh
Created February 19, 2018 09:10
Set up mongo db and add admin
51
52
53
#!/bin/bash
# Admin User
MONGODB_ADMIN_USER=${MONGODB_ADMIN_USER:-"admin"}
MONGODB_ADMIN_PASS=${MONGODB_ADMIN_PASS:-"4dmInP4ssw0rd"}
#!/bin/sh
### BEGIN INIT INFO
# Provides: disable-transparent-hugepages
# Required-Start: $local_fs
# Required-Stop:
# X-Start-Before: mongod mongodb-mms-automation-agent
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Disable Linux transparent huge pages
# Description: Disable Linux transparent huge pages, to improve
@Buffer0x7cd
Buffer0x7cd / snakeeat.py
Last active September 21, 2017 09:53
Solution for snakeeat problem codechef( Getting a TLE)
''' Problem link: https://www.codechef.com/problems/SNAKEEAT
Approach
1: Get the maximum index x for which a[x] < K
2: set the search space for L with lower bound of 0 and upper bound of x+1
3: find the maximum value of l for which eq. K*L - sum(X-L+1,X) <= X-L+1 holds true
'''
def getValue(a,num):
'''Return the largest value of i for which a[i] < k'''
low = 0