Skip to content

Instantly share code, notes, and snippets.

View icyflame's full-sized avatar

Siddharth Kannan icyflame

View GitHub Profile
@samoshkin
samoshkin / toggle_keybindings.tmux.conf
Last active February 5, 2024 02:26
tmux.conf excerpt to toggle on/off session keybindings and prefix handling
bind -T root F12 \
set prefix None \;\
set key-table off \;\
set status-style "fg=$color_status_text,bg=$color_window_off_status_bg" \;\
set window-status-current-format "#[fg=$color_window_off_status_bg,bg=$color_window_off_status_current_bg]$separator_powerline_right#[default] #I:#W# #[fg=$color_window_off_status_current_bg,bg=$color_window_off_status_bg]$separator_powerline_right#[default]" \;\
set window-status-current-style "fg=$color_dark,bold,bg=$color_window_off_status_current_bg" \;\
if -F '#{pane_in_mode}' 'send-keys -X cancel' \;\
refresh-client -S \;\
bind -T off F12 \
@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|
@icyflame
icyflame / c-cheatsheet.md
Last active July 13, 2017 06:39
A cheat sheet for some of the common c code that's often used

#define

#define iterate(i, n) for (i = 0; i < n; ++i)
#define print_int_arr(arr, i, n) for (i = 0; i < n; ++i) printf("%d, ", arr[i]);

qsort

@icyflame
icyflame / replace.js
Last active May 19, 2017 07:17
Replace commas according to the Indian numbering system
t = [1, 12, 123, 1234, 12345,
123456, 1234567, 12345678,
123456789, 1234567890,
12345678901, 123456789012];
function convert(x) {
return x.toString().substr()
.replace(/\B(?=\d{3}$)/g, ",")
.replace(/\B(?=(\d{2})+(?!\d),)/g, ",")
};
@icyflame
icyflame / vimrc
Last active January 29, 2017 05:28
the vimrc to roll with when you are thrust onto a new machine with vanilla vim
set mouse=a
set expandtab
set shiftwidth=2
set softtabstop=2
set tw=80
syntax on
filetype plugin on
@icyflame
icyflame / http proxy list of files.md
Last active January 13, 2018 17:20
Because clearing the http proxy settings is more of a pain than finding the right settings to use in the first place
Location Variable names Command to check if this variable still exists
~/dotfiles/.local/kgp.zsh HTTP_PROXY, HTTPS_PROXY, http_proxy, https_proxy `export
~/.gitconfig Git variables for http and https proxies git config --list
~/.bowerrc proxy and https-proxy used by Gulp No command, check the file itself. remove or change variable name in the file
~/.npmrc http-proxy and https-proxy used by NPM No command, check the file and remove or change
/etc/systemd/system/docker.service.d/http-proxy.conf Environment used by Docker to pull images systemctl show --property=Environment docker => Output should be Environment= (if it shows proxy, then this file needs to be changed) Tutorial
Operation Code
New List List<Integer> x = new ArrayList<Integer>();
Copy List List<Integer> x = new ArrayList<Integer>(y);
Add an element to the List x.add(element)
Get an elemenet from the List x.get(index)
Clear the list x.clear()
New HashMap HashMap<Integer, String> x = new HashMap<Integer, String>();
Add element to the map x.put(key, value)
Get an element from the map x.get(key)
function findZip(dir, callback) {
var fs = require('fs');
var fileList = fs.readdirSync(dir);
var candidates = [];
for(i in fileList) {
if (fileList[i].match(/.zip$/)) {
candidates.push(fileList[i]);
}
}
if (candidates.length == 1) {
@icyflame
icyflame / Interview.txt
Last active September 12, 2016 05:30 — forked from arafatkamaal/Interview.txt
Interview tips
Almost all of the questions posted in this sub are some form of "what do I have to know/do to pass a tech interview/get a job." Here's some distilled advice I can offer from having conducted over 1000 tech interviews. This doesn't cover everything, but I think it covers the most important foundational elements.
Setting expectations: If this is your first time looking for a job, or you haven't had to interview in a number of years, expect to invest some effort in preparing for the interview. It's usually the industry professionals that completely ignore this step, but some college students do as well. You're essentially studying for a test, don't slack off - it's going to be work. All of those things that you've been telling yourself don't matter (maybe you're a bit fuzzy on how exactly the internet works - do you really know what happens after you hit enter on the URL bar?) that you don't know - now it's time to address those gaps head on. So, what matter.
For the sake of space, I'm going to focus on what a
@icyflame
icyflame / README.md
Created May 26, 2016 04:34 — forked from gabrielemariotti/README.md
A SectionedGridRecyclerViewAdapter: use this class to realize a simple sectioned grid `RecyclerView.Adapter`.

You can use this class to realize a simple sectioned grid RecyclerView.Adapter without changing your code.

Screen

The RecyclerView has to use a GridLayoutManager.

This is a porting of the class SimpleSectionedListAdapter provided by Google

If you are looking for a sectioned list RecyclerView.Adapter you can take a look here