Skip to content

Instantly share code, notes, and snippets.

View arpitbbhayani's full-sized avatar
🎲
building @DiceDB

Arpit Bhayani arpitbbhayani

🎲
building @DiceDB
View GitHub Profile
Vagrant.configure('2') do |config|
config.vm.hostname = 'practo-piez.dev'
config.package.name = 'piez.box'
config.vm.box = 'piez.box'
config.vm.box_url = 'http://ncc04.practo.in/appmgr/piez.box'
if config.vm.respond_to? 'box_download_insecure' # Vagrant 1.2.6+
config.vm.box_download_insecure = true
end
config.ssh.insert_key = true
config.ssh.shell = "bash -c 'BASH_ENV=/etc/profile exec bash'"
@arpitbbhayani
arpitbbhayani / myjupyter
Created February 9, 2017 09:39
My Jupyter Setup
```
conda install -c conda-forge jupyter_contrib_nbextensions
```
@arpitbbhayani
arpitbbhayani / index.js
Created May 12, 2017 21:19
Semantic UI - Dropdown prevent on enter form submit
$('.ui.dropdown').dropdown({
keys: {
delimiter: 13
}
});
@arpitbbhayani
arpitbbhayani / gist:4a66909b57ecc9eb6807f327b62cb51e
Created July 18, 2019 15:00
Serve static files only from Flask
# Hangman UI
#
# Installing required packages
# $ pip install flask
#
# Run
# $ python ui.py
#
from flask import Flask
@arpitbbhayani
arpitbbhayani / server.py
Created July 20, 2019 15:27
flask-static-server
# Hangman UI
#
# Installing required packages
# $ pip install flask
#
# Run
# $ python ui.py
#
from flask import Flask
@arpitbbhayani
arpitbbhayani / benchmark.cpp
Created September 4, 2019 16:27
Benchmark - Stopping loop iteration
#include <cstdio>
#include <ctime>
#include <sys/time.h>
#define SIZE 1000000001
char str[SIZE];
void with_break(char *str) {
bool a_found = false;
@arpitbbhayani
arpitbbhayani / ceval.c
Created January 2, 2020 19:28
Python code to evaluate addition of two operands
case TARGET(BINARY_ADD): {
PyObject *right = POP();
PyObject *left = TOP();
PyObject *sum;
if (PyUnicode_CheckExact(left) &&
PyUnicode_CheckExact(right)) {
sum = unicode_concatenate(tstate, left, right, f, next_instr);
}
else {
sum = PyNumber_Add(left, right);
@arpitbbhayani
arpitbbhayani / ceval.c
Created January 2, 2020 19:30
Checking if both the python objects (operands) are numbers.
if (PyNumber_Check(left) && PyNumber_Check(right)) {
// Both the operands are numbers
}
@arpitbbhayani
arpitbbhayani / ceval.c
Created January 2, 2020 19:30
generating random number using datetime.h in c
int
get_random_number(int max) {
return time(NULL) % max;
}
@arpitbbhayani
arpitbbhayani / ceval.c
Created January 2, 2020 19:31
Binary operate
PyObject *
binary_operate(PyObject * left, PyObject * right, char operator) {
switch (operator) {
case '+':
return PyNumber_Add(left, right);
case '-':
return PyNumber_Subtract(left, right);
case '*':
return PyNumber_Multiply(left, right);
case '/':