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 July 9, 2024 17:07
How is git commit sha1 formed

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

When I added FIRST/NEXT/LAST, it was idiomatic but not quite so fast. This makes it faster. Another little bit of masak++'s program.

@thebucknerlife
thebucknerlife / authentication_with_bcrypt_in_rails_4.md
Last active July 10, 2024 00:17
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 July 11, 2024 07:00
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 June 21, 2024 15:04
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 = ""
@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()
@Saakshaat
Saakshaat / idea.md
Last active June 29, 2020 08:24
Terminal Notes

Terminal

Terminal's every developer's best friend; I use mine terminal for almost everything, writing/executing custom scripts, restarting Spotify, opening different IDEs/Editors and what not.

When a new session pops up, my main focus is make minimal efforts and optimise productivity, which, for me is driven by streamlining my priorites and deliverables.

Thus, I had to find a way to combine my terminal and notes/TODOs, and here we are.

Setup