Skip to content

Instantly share code, notes, and snippets.

View swaathi's full-sized avatar
💃

Swaathi Kakarla swaathi

💃
View GitHub Profile
@0sc
0sc / encrypt_decrypt.rb
Created January 12, 2018 16:12
Simple encrypt decrypt strings in ruby
require 'openssl'
def encrypt_string(str)
cipher_salt1 = 'some-random-salt-'
cipher_salt2 = 'another-random-salt-'
cipher = OpenSSL::Cipher.new('AES-128-ECB').encrypt
cipher.key = OpenSSL::PKCS5.pbkdf2_hmac_sha1(cipher_salt1, cipher_salt2, 20_000, cipher.key_len)
encrypted = cipher.update(str) + cipher.final
encrypted.unpack('H*')[0].upcase
end
@fuglede
fuglede / tensorflow101.ipynb
Last active August 30, 2023 06:45
TensorFlow 101
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@swaathi
swaathi / dijkstras.py
Last active October 27, 2019 00:39
Dijkstra's Algorithm with Python
from collections import defaultdict
class Graph:
def __init__(self, start, end):
self.nodes = set()
self.edges = defaultdict(list)
self.distances = {}
self.start = start
self.end = end
def add_node(self, value):
@andrewlimaza
andrewlimaza / example.html
Created December 19, 2016 11:31
Print certain div / elements using window.print()
<script>
function printDiv(divName){
var printContents = document.getElementById(divName).innerHTML;
var originalContents = document.body.innerHTML;
document.body.innerHTML = printContents;
window.print();
document.body.innerHTML = originalContents;
@staltz
staltz / introrx.md
Last active November 17, 2024 01:08
The introduction to Reactive Programming you've been missing
@varun-raj
varun-raj / pullJSON.js
Last active October 31, 2022 16:19
Google App Script To Fetch Data From JSON Webservice and Write them to google spreadsheet.
function pullJSON() {
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheets = ss.getSheets();
var sheet = ss.getActiveSheet();
var url="http://example.com/feeds?type=json"; // Paste your JSON URL here
var response = UrlFetchApp.fetch(url); // get feed
var dataAll = JSON.parse(response.getContentText()); //
@mabdrabo
mabdrabo / sound_recorder.py
Created January 28, 2014 23:05
Simple script to record sound from the microphone, dependencies: easy_install pyaudio
import pyaudio
import wave
FORMAT = pyaudio.paInt16
CHANNELS = 2
RATE = 44100
CHUNK = 1024
RECORD_SECONDS = 5
WAVE_OUTPUT_FILENAME = "file.wav"
@joost
joost / update_cache_counters.rake
Last active September 25, 2018 15:05 — forked from svyatov/update_cache_counters.rake
Rails Rake Task: Update all cache counters / counter caches.
# More robust version to update new or existing counter cache columns in your Rails app.
# See: https://gist.github.com/svyatov/4225663
desc 'Update all cache counters'
task :update_cache_counters => :environment do
models_to_update = {}
# or: Rails.application.eager_load!
# Dir loads less, so it's faster
Dir.glob(Rails.root.join('app/models/**/*')).each { |model| require model if File.file?(model) }
@garyharan
garyharan / colorize.rb
Last active June 3, 2024 15:06
Simple rails logging output colorize
#!/usr/bin/env ruby -w
# SETUP:
# (assumes ~/bin/ is in your path)
# cp colorize.rb ~/bin/colorize
# chmod +x ~/bin/colorize
# USAGE:
# tail -f log/development.log | colorize
class String
@linjunpop
linjunpop / README.md
Created August 21, 2012 01:15
Rails flash messages with AJAX requests