Skip to content

Instantly share code, notes, and snippets.

View intentionally-left-nil's full-sized avatar

Anil Kulkarni intentionally-left-nil

View GitHub Profile
def first_initials(names)
names.reduce({}) do |letters, name|
first_letter = name[0]
if letters[first_letter] == nil
letters[first_letter] = 1
else
letters[first_letter] += 1
end
letters
end
@intentionally-left-nil
intentionally-left-nil / setup.sh
Last active September 26, 2017 00:36
Setting up eslint in atom
#! /bin/bash
npm install -g eslint eslint-config-react-app babel-eslint eslint-plugin-flowtype eslint-plugin-import eslint-plugin-jsx-a11y eslint-plugin-react
apm install linter linter-eslint
echo '{' > ~/.eslintrc
echo ' "extends": "react-app",' >> ~/.eslintrc
echo ' "env":' { >> ~/.eslintrc
echo ' "browser": true,' >> ~/.eslintrc
echo ' "jquery": true,' >> ~/.eslintrc
echo ' "jasmine": true' >> ~/.eslintrc
echo ' }' >> ~/.eslintrc
@intentionally-left-nil
intentionally-left-nil / Gemfile
Created October 17, 2017 18:46
Rails test setup
group :test do
gem 'rspec-rails'
gem 'simplecov', require: false
gem 'rails-controller-testing'
gem 'shoulda-matchers'
gem 'faker'
gem 'capybara'
gem 'poltergeist'
gem 'factory_girl_rails'
@intentionally-left-nil
intentionally-left-nil / update_cloudfront_ssl.py
Created October 27, 2017 22:41
Updating a cloudfront SSL certificate via boto
import boto3
import os
from copy import deepcopy
acm = boto3.client('acm')
cloudfront = boto3.client('cloudfront')
cf_ids = ['YOUR_CLOUDFRONT_ID_HERE', 'YOUR_SECOND_CLOUDFRONT_ID_HERE']
base = 'DIRECTORY_TO_YOUR SSL CERTS'
cert_arn = None
@intentionally-left-nil
intentionally-left-nil / download.py
Created November 2, 2017 23:45
download files from slack
import os
from slackclient import SlackClient
import requests
slack_token = os.environ["SLACK_API_TOKEN"]
sc = SlackClient(slack_token)
if not os.path.exists('files'):
os.makedirs('files')
channels = sc.api_call("channels.list")["channels"]
@intentionally-left-nil
intentionally-left-nil / README.md
Last active February 22, 2018 07:14 — forked from jasonblanchard/README.md
Watching build mode on Create React App

Create React App does not provide watching build mode oficially (#1070).

This script provides watching build mode for an external tool such as Chrome Extensions or Firebase app. You can either build the dev bundle once with build:dev, or continually rebuild it with watch

How to Use

Create a React app.

Put the script into scripts/build.js.

@intentionally-left-nil
intentionally-left-nil / deloldtweets.py
Last active July 27, 2022 10:33 — forked from flesueur/deloldtweets.py
Delete (very) old tweets obtained from a twitter archive
#!/bin/python3
# Largely copied from http://www.mathewinkson.com/2015/03/delete-old-tweets-selectively-using-python-and-tweepy
# However, Mathew's script cannot delete tweets older than something like a year (these tweets are not available from the twitter API)
# This script is a complement on first use, to delete old tweets. It uses your twitter archive to find tweets' ids to delete
# How to use it :
# - download and extract your twitter archive (tweet.js will contain all your tweets with dates and ids)
# - put this script in the extracted directory
# - complete the secrets to access twitter's API on your behalf and, possibly, modify days_to_keep
# - delete the few junk characters at the beginning of tweet.js, until the first '[' (it crashed my json parser)
# - review the script !!!! It has not been thoroughly tested, it may have some unexpected behaviors...
@intentionally-left-nil
intentionally-left-nil / scaled_ga_winner.py
Last active January 6, 2021 04:20
Takes the current vote counts per-county and extrapolates them to 100%
import urllib.request
import json
headers = {'Referrer': 'https://results.decisiondeskhq.com/', 'Accept': 'application/json',
'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10.16; rv:84.0) Gecko/20100101 Firefox/84.0'}
url = 'https://embeds.ddhq.io/api/v2/2020general_results/2021senate_ga'
request = urllib.request.Request(url, headers=headers)
response = json.load(urllib.request.urlopen(request))
for data in response['data']:
candidates = data['candidates']
@intentionally-left-nil
intentionally-left-nil / arch-secure-install.md
Created August 18, 2021 04:37 — forked from umbernhard/arch-secure-install.md
Building a Secure Arch Linux Device

Building a Secure Arch Linux Device

Locking down a linux machine is getting easier by the day. Recent advancements in systemd-boot have enabled a host of features to help users ensure that their machines have not been tampered with. This guide provides a walkthrough of how to turn on many of these features during installation, as well as reasoning for why certain features help improve security.

The steps laid out below draw on a wide variety of existing resources, and in places I'll point to them rather than attempt to regurgitate full explanations of the various security components. The most significant one, which I highly encourage everyone to read, is Rod Smith's site about secure boot, which is the most comprehensive and cogent explanation of UEFI, boot managers and boot loaders, and secure boot. Another incredibly useful resources is Safeboot, which encapsulates many of the setup steps below in a Debian application.

@intentionally-left-nil
intentionally-left-nil / server.py
Created August 16, 2023 06:36
python-cookie-cors-investigation
from http.server import HTTPServer, BaseHTTPRequestHandler
from http.cookies import SimpleCookie
import json
class Handler(BaseHTTPRequestHandler):
def add_cors(self):
host = self.headers.get('Origin', '*')
self.send_header('Access-Control-Allow-Origin', host)