Skip to content

Instantly share code, notes, and snippets.

View vividvilla's full-sized avatar

Vivek R vividvilla

View GitHub Profile
@vividvilla
vividvilla / pykiteconnect_streaming_threaded.py
Last active March 9, 2022 17:54
Test Kite Connect data streaming with threaded Raw
import time
import logging
from kiteconnect import WebSocket
logging.basicConfig(level=logging.DEBUG, format='%(asctime)s - %(name)s - %(levelname)s - %(message)s')
# Initialise.
kws = WebSocket("api_key", "public_token", "zerodha_user_id")
# RELIANCE BSE and RELIANCE NSE
@vividvilla
vividvilla / ca.md
Created January 31, 2022 06:47 — forked from soarez/ca.md
How to setup your own CA with OpenSSL

How to setup your own CA with OpenSSL

For educational reasons I've decided to create my own CA. Here is what I learned.

First things first

Lets get some context first.

@vividvilla
vividvilla / custom_time.go
Created June 10, 2021 07:01 — forked from lummie/custom_time.go
Golang custom date / time formats when marshalling to JSON
// CustomTime provides an example of how to declare a new time Type with a custom formatter.
// Note that time.Time methods are not available, if needed you can add and cast like the String method does
// Otherwise, only use in the json struct at marshal/unmarshal time.
type CustomTime time.Time
const ctLayout = "2006-01-02 15:04:05 Z07:00"
// UnmarshalJSON Parses the json string in the custom format
func (ct *CustomTime) UnmarshalJSON(b []byte) (err error) {
/* Program for Printing first N terms of Fibonacci series using for loop (without taking input from user)
* Code by Vivek R (vividvilla) - Contact me at - http://vivek.techiestuffs.com
*/
public class FibonacciFor {
public static void main(String[] args)
{
int n=10,first=0,second=1,next,i;
System.out.println("Printing first "+n+" numbers in Fibonacci Series \n");
@vividvilla
vividvilla / migrate-fish-history-to-zsh.py
Created December 26, 2019 06:57 — forked from mateuspontes/migrate-fish-history-to-zsh.py
Migrate fish history to zsh shell (python 2.7)
import os
import re
def fish_to_zsh(cmd):
return (cmd.replace('; and ', '&&')
.replace('; or ', '||'))
with open(os.path.expanduser('~/.zsh_history.test'), 'a') as o:
with open(os.path.expanduser('~/.local/share/fish/fish_history')) as f:
for line in f:
@vividvilla
vividvilla / nginx.conf
Created November 28, 2018 10:07
Nginx POST and GET request serve static JSON
server {
listen 9999;
# This is the key.
error_page 405 =200 $uri;
location /test {
add_header 'Content-Type' 'application/json' always;
alias /Users/me/abc.json;
}
}
@vividvilla
vividvilla / sale-flash.php
Last active October 18, 2018 10:10
Display Discount/Offer percentage in WooCommerce
<?php
/**
* Product loop sale flash
*
* @author Vivek R @ WPSTuffs.com
* @package WooCommerce/Templates
* @version 1.6.4
*/
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
@vividvilla
vividvilla / simplesessions_callbacks.go
Created October 1, 2018 20:34
Callbacks for simplesession
func getCookie(name string, r interface{}) (*http.Cookie, error) {
rd := r.(*http.Request)
cookie, err := rd.Cookie(name)
if err != nil {
return nil, err
}
return cookie, nil
}
func setCookie(cookie *http.Cookie, w interface{}) error {
@vividvilla
vividvilla / archive.php
Created January 10, 2014 06:56
Archive functions
// Display weekly archives
<?php wp_get_archives('type=weekly'); ?>
// Last 10 weeks archive
<?php wp_get_archives('type=weekly&limit=10'); ?>
// Monthly archive with post count
log_format timed_combined '$remote_addr - $remote_user [$time_local] '
'"$request" $status $body_bytes_sent '
'"$http_referer" "$http_user_agent" '
'$request_time $upstream_response_time $pipe';