Skip to content

Instantly share code, notes, and snippets.

View nisanthchunduru's full-sized avatar

Nisanth Chunduru nisanthchunduru

View GitHub Profile
@nisanthchunduru
nisanthchunduru / neural_network.py
Created November 13, 2023 10:18
Simple Neutral Network from scratch
# This program was generated by ChatGPT
import numpy as np
# Sigmoid activation function
def sigmoid(x):
return 1 / (1 + np.exp(-x))
# Derivative of the sigmoid function
def sigmoid_derivative(x):
@nisanthchunduru
nisanthchunduru / clone_and_restore_server_harddisk.md
Last active August 1, 2023 07:52
Clone and restore a physical server's harddisk

Clone a server's harddisk

Login to Hetzner's web interface https://robot.your-server.de/ and activate the Rescue System for the server whose disk you wish to clone.

Ssh into the Rescue System (Replace 1.2.3.4 in the command below with the actual ip address of the server)

ssh -o HostKeyAlias=hetzner-rescue.1.2.3.4 root@1.2.3.4
@nisanthchunduru
nisanthchunduru / application.rb
Created June 26, 2023 12:44
Log responses in Rails in development environment
# In config/application.rb
class ResponseLogger
def initialize(app)
@app = app
end
def call(env)
headers = env.select {|k,v| k.start_with? 'HTTP_'}
.map {|pair| [pair[0].sub(/^HTTP_/, ''), pair[1]].join(": ")}
@nisanthchunduru
nisanthchunduru / teach_web_dev.md
Last active May 17, 2023 01:56
Teach web dev

Structs & functions

#include <stdio.h>
#include <string.h>

int stringsTotalLength(char* firstString, char* secondString) {
  int totalLength = strlen(firstString) + strlen(secondString);
  return totalLength;
}
.fadeinDown {
-webkit-animation: fadeInDown 500ms ease-in-out; /* Chrome, Safari, Opera */
animation: fadeInDown 500ms ease-in-out;
}
/* Chrome, Safari, Opera */
@-webkit-keyframes fadeInDown {
0% {
@nisanthchunduru
nisanthchunduru / delete_failed_jobs.rb
Last active September 15, 2022 18:37
Selectively remove/retry failed jobs in Resque 1.x
def delete_failed_job_if
redis = Resque.redis
(0...Resque::Failure.count).each do |i|
string = redis.lindex(:failed, i)
break if string.nil?
job = Resque.decode(string)
should_delete_job = yield job
next unless should_delete_job
@nisanthchunduru
nisanthchunduru / gist:d341ab22dede19e572d0e8152393e93a
Created June 8, 2021 13:40 — forked from ryanbriones/gist:246599
send email to gmail (STARTTLS) using ruby >=1.8.7
# send email using STARTTLS; Net::SMTP#enable_starttls requires ruby >=1.8.7
# this hack is needed for rails <2.3; apparently >=2.3 has something for this already
ActionMailer::Base.class_eval do
private
def perform_delivery_smtp(mail)
destinations = mail.destinations
mail.ready_to_send
smtp = Net::SMTP.new(smtp_settings[:address], smtp_settings[:port])
@nisanthchunduru
nisanthchunduru / edid-decode source URL
Created July 27, 2017 19:35 — forked from OneSadCookie/edid-decode source URL
EDID decoding on the Mac, to find out what resolutions and rates the Mac is seeing reported.
http://cgit.freedesktop.org/xorg/app/edid-decode/plain/edid-decode.c
compile with:
gcc edid-decode.c -o edid-decode
get EDID from IORegistryExplorer (mine, an old 24" Apple Cinema Display, is attached).
Convert to binary with this command:
ruby -e 'File.open("edid", "wb").write(File.read("edid.txt").split.map { |s| ("0x"+s).to_i(16) }.inject("", "<<"))'
@nisanthchunduru
nisanthchunduru / GETTING_STARTED.md
Created June 17, 2016 06:23
Factory Girl 3.2.0 Getting Started Guide

Getting Started

Update Your Gemfile

If you're using Rails, you'll need to change the required version of factory_girl_rails:

gem "factory_girl_rails", "~&gt; 3.0"
@nisanthchunduru
nisanthchunduru / gist:4608499
Last active February 13, 2020 09:38
Installing nodejs on debian using checkinstall
#!/bin/sh
##############################################################
#
# Rock-Solid Node.js Platform on Ubuntu
# Auto-config by apptob.org
# Author: Ruslan Khissamov, email: rrkhissamov@gmail.com
# GitHub: https://github.com/rushis
#
##############################################################