Skip to content

Instantly share code, notes, and snippets.

View icyflame's full-sized avatar

Siddharth Kannan icyflame

View GitHub Profile
package main
import (
"fmt"
"golang.org/x/net/html"
"log"
"strings"
)
// return the first tag in subtree for which reqd returns true (DFS)
@icyflame
icyflame / t.diff
Last active February 2, 2018 13:31
< {
< "Department": "mechanical engineering",
< "Semester": "mid autumn 2016",
< "Paper": "systems and control",
< "Link": "https://drive.google.com/open?id=0B9VL20IzhCr7ZDRDUlVDNjk4Z0k",
< "Year": "2016"
< },
< {
< "Department": "mechanical engineering",
< "Semester": "end spring 2017",
@icyflame
icyflame / twitter_get_access_tok.go
Created December 15, 2017 04:33
Get app authentication access token for the Twitter API in Golang
package main
import b64 "encoding/base64"
import "encoding/json"
type BearerToken struct {
Token_Type string
Access_Token string
}
@icyflame
icyflame / app-auth.go
Last active December 15, 2017 03:18
go-twitter library - app authentication doesn't fetch user timelines
package main
import (
"fmt"
"github.com/dghubble/go-twitter/twitter"
"golang.org/x/oauth2"
"os"
)
func main() {
<OpenSearchDescription>
<ShortName>Google Encrypted</ShortName>
<Description>search on encrypted.google.com - websites get less data about you</Description>
<Image height="16" width="16" type="image/x-icon">https://www.google.com/favicon.ico</Image>
<Url type="text/html" method="get" template="https://encrypted.google.com/search?q={searchTerms}" />
</OpenSearchDescription>
@icyflame
icyflame / c++-cheatsheet.md
Last active October 27, 2017 12:04
A cheat sheet for C++

SORT

include algorithm, vector in C++11

int *arr = NULL;
arr = (int *) malloc(sizeof(int) * len);
std::vector<int> arrv(arr, arr+len);
int temp; cin >> temp;
arrv.push_back(temp); // add an element to the array
std::sort(arrv.begin(), arrv.end()); // MERGE SORT
arrv.clear(); // empty the array
@icyflame
icyflame / links_all1.txt
Created October 1, 2017 14:11
Criminal podcast - episode-wise mp3 links
@icyflame
icyflame / whatswrong.cpp
Created September 24, 2017 18:14
Merge sort - something's WRONG
#include <stdlib.h>
#include <iostream>
using namespace std;
int * merge_sort(int *A, int begin, int end) {
if (end - begin <= 1) {
return A;
}
@icyflame
icyflame / simple_format.rb
Created August 12, 2017 07:45
the ActionView::Helpers::TextHelper simple_format function for use outside Rails apps
require 'action_view'
NOTICE_ATTRIBS = 5
TOP_NOTICES = 5
# https://apidock.com/rails/v4.2.1/ActionView/Helpers/TextHelper/split_paragraphs
def split_paragraphs(text)
return [] if text.blank?
text.to_str.gsub(/\r\n?/, "\n").split(/\n\n+/).map! do |t|