Skip to content

Instantly share code, notes, and snippets.

View harsh183's full-sized avatar
😺
People pleasing users

Harsh Deep harsh183

😺
People pleasing users
View GitHub Profile
@icco
icco / license
Created November 16, 2010 19:50 — forked from defunkt/license
MIT License Gist
#!/bin/sh -e
# Usage: license
# Prints an MIT license appropriate for totin' around.
#
# $ license > COPYING
#!/bin/sh
echo "Copyright (c) `date +%Y` Nathaniel Welch
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
@masak
masak / explanation.md
Last active May 4, 2026 22:37
How is git commit sha1 formed

(The below text is licensed with CC0, which means that if you want to use or translate it, that is OK by me.)

Ok, I geeked out, and this is probably more information than you need. But it completely answers the question. Sorry. ☺

Locally, I'm at this commit:

$ git show
commit d6cd1e2bd19e03a81132a23b2025920577f84e37
Author: jnthn <jnthn@jnthn.net>

Date: Sun Apr 15 16:35:03 2012 +0200

@thebucknerlife
thebucknerlife / authentication_with_bcrypt_in_rails_4.md
Last active March 12, 2025 18:03
Simple Authentication in Rail 4 Using Bcrypt

#Simple Authentication with Bcrypt

This tutorial is for adding authentication to a vanilla Ruby on Rails app using Bcrypt and has_secure_password.

The steps below are based on Ryan Bates's approach from Railscast #250 Authentication from Scratch (revised).

You can see the final source code here: repo. I began with a stock rails app using rails new gif_vault

##Steps

@lukas-h
lukas-h / license-badges.md
Last active May 12, 2026 01:58
Markdown License Badges for your Project

Markdown License badges

Collection of License badges for your Project's README file.
This list includes the most common open source and open data licenses.
Easily copy and paste the code under the badges into your Markdown files.

Notes

  • The badges do not fully replace the license informations for your projects, they are only emblems for the README, that the user can see the License at first glance.

Translations: (No guarantee that the translations are up-to-date)

@0cjs
0cjs / initialize_vars.rb
Last active September 4, 2022 16:40
Replace boilerplate Ruby `def initialize` followed by instance variable settings with `initialize_vars` specifying variables once
# XXX This worked in 2009 with Ruby 1.8; I've not tested on anything
# more recent. But you get the general idea.
class Class
def initialize_vars(*vars, &initialize_block)
vars.each { |arg| attr_reader arg.to_sym }
varsyms = vars.collect { |arg| ('@' + arg.to_s).to_sym }
define_method(:initialize) { |*init_args|
raise(ArgumentError, "wrong number of arguments " +
@jirihnidek
jirihnidek / getaddrinfo_example.c
Last active February 9, 2025 12:12
Example of getaddrinfo() program.
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <netdb.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <arpa/inet.h>
int
lookup_host (const char *host)
@harsh183
harsh183 / numbersToWords.rb
Last active November 5, 2017 11:03
To convert number to words in ruby (for any positive integer)
def toWords(num)
units = ['Zero', 'One', 'Two', 'Three', 'Four', 'Five', 'Six', 'Seven', 'Eight', 'Nine']
tens = ['', '', 'Twenty', 'Thirty', 'Fourty', 'Fifty', 'Sixty', 'Seventy', 'Eighty', 'Ninety']
teens = ['Ten', 'Eleven', 'Tweleve', 'Thirteen', 'Fourteen', 'Fifteen', 'Sixteen',
'Seventeen', 'Eighteen', 'Nineteen']
units_digit = num % 10
tens_digit = num / 10
number_in_words = ""
@mohanpedala
mohanpedala / bash_strict_mode.md
Last active May 14, 2026 06:10
set -e, -u, -o, -x pipefail explanation
@gtr
gtr / cats.jpg
Last active March 14, 2020 10:32
cats.jpg
@sureshbabua8
sureshbabua8 / app.kt
Last active January 13, 2020 00:11
Simple GET Request in Kotlin
import com.squareup.moshi.JsonClass
import com.squareup.moshi.Moshi
import com.squareup.moshi.kotlin.reflect.KotlinJsonAdapterFactory
import okhttp3.OkHttpClient
import okhttp3.Request
import java.io.IOException
class ParseResponseWithMoshi {
private val client = OkHttpClient()
private val moshi = Moshi.Builder().add(KotlinJsonAdapterFactory()).build()