Skip to content

Instantly share code, notes, and snippets.

View DravitLochan's full-sized avatar
🍃
creating magic

Dravit Lochan DravitLochan

🍃
creating magic
View GitHub Profile
@loicpw
loicpw / index.html
Created January 18, 2019 00:57
Responsive Web Design Projects - Build a Survey Form
<script src="https://cdn.freecodecamp.org/testable-projects-fcc/v1/bundle.js"></script>
<!--
Hello Camper!
For now, the test suite only works in Chrome! Please read the README below in the JS Editor before beginning. Feel free to delete this message once you have read it. Good luck and Happy Coding!
- The freeCodeCamp Team
@ateucher
ateucher / setup-gh-cli-auth-2fa.md
Last active May 3, 2024 11:06
Setup git on the CLI to use 2FA with GitHub

These are instructions for setting up git to authenticate with GitHub when you have 2-factor authentication set up. This authentication should be inherited by any GUI client you are using. These are intentionally brief instructions, with links to more detail in the appropriate places.

  1. Download and install the git command-line client (if required).

  2. Open the git bash window and introduce yourself to git (if required):

    git config --global user.name 'Firstname Lastname'
    git config --global user.email 'firstname.lastname@gov.bc.ca'
    
@Mariovc
Mariovc / ImagePicker.java
Last active February 7, 2024 23:33
Utility for picking an image from Gallery/Camera with Android Intents
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.content.pm.ResolveInfo;
import android.content.res.AssetFileDescriptor;
import android.database.Cursor;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Matrix;
import android.media.ExifInterface;
@dhavaln
dhavaln / Decompress.java
Last active December 14, 2022 10:01
Android Download and Unzip File
package com.jumpbyte.webserver;
import android.content.Context;
import android.util.Log;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileDescriptor;
import java.io.FileInputStream;
import java.io.FileOutputStream;
@lfender6445
lfender6445 / gist:9919357
Last active May 2, 2024 22:40
Pry Cheat Sheet

Pry Cheat Sheet

Command Line

  • pry -r ./config/app_init_file.rb - load your app into a pry session (look at the file loaded by config.ru)
  • pry -r ./config/environment.rb - load your rails into a pry session

Debugger

@pythonicrubyist
pythonicrubyist / nil_empty_blank_present_ffdierence_in_ruby
Last active February 21, 2024 17:38
Difference between nil?, empty?, blank? and present? in Ruby and Ruby on Rasils.
# nil? can be used on any Ruby object. It returns true only if the object is nil.
nil.nil? # => true
[].nil? # => false
{}.nil? # => false
"".nil? # => false
" ".nil? # => false
true.nil? # => false
# empty? can be used on some Ruby objects including Arrays, Hashes and Strings. It returns true only if the object's length is zero.
nil.empty? # NoMethodError: undefined method `empty?' for nil:NilClass
@yingted
yingted / copy-clipboard-from-android.sh
Created September 14, 2013 05:43
Copy Android clipboard over ssh or adb to the local clipboard. Set login to -d or -e to force adb to only look for devices or emulators. See also copy-clipboard-to-android.sh.
#!/bin/sh
# Copies the Android clipboard to local X11 secondary buffer.
# Useful for debugging.
limit=33
delay=3000
login=my-android-ssh-name # ssh $login or adb $login shell should log you in
while getopts 't:h:q' opt
do
case $opt in
@aalinat
aalinat / contact.html.erb
Created July 14, 2012 22:43
rails upload attachment (contact form)
<h1>Contact</h1>
<%= form_tag("/send_to", :method=>'post', :multipart => true) do %>
<p>
Subject:<br />
<%= text_field_tag "subject" %>
</p>
<p>
Priority: <br />
@chitan
chitan / WsChatServlet.java
Created July 7, 2012 01:44
How to use WebSocket of Tomcat
//This sample is how to use websocket of Tomcat.
package wsapp;
import java.io.IOException;
import java.nio.ByteBuffer;
import java.nio.CharBuffer;
import java.util.ArrayList;
import org.apache.catalina.websocket.MessageInbound;
import org.apache.catalina.websocket.StreamInbound;
import org.apache.catalina.websocket.WebSocketServlet;