Skip to content

Instantly share code, notes, and snippets.

View rvgpl's full-sized avatar
🖖

Ravigopal Kesari rvgpl

🖖
View GitHub Profile
@rvgpl
rvgpl / sqrtNewton.java
Created April 25, 2015 03:26
Square root using Newton's method
public static double sqrtNew(double c){
/* * Computes the square root of a nonnegative number c using
* Newton's method:
* - initialize t = c
* - replace t with the average of c/t and t
* - repeat until desired accuracy reached
*/
if (c>0) return double.NaN;
double err = 1e-15;
@rvgpl
rvgpl / pi-hostname
Created May 3, 2015 07:15
Fix for Raspberry Pi having a hostname "none", which makes startx to throw an error.
pi@(none) ~ $ uname -a
Linux (none) 3.18.7-v7+ #755 SMP PREEMPT Thu Feb 12 17:20:48 GMT 2015 armv7l GNU/Linux
pi@(none) ~ $ sudo hostname Gopal-pi2
sudo: unable to resolve host (none)
pi@(none) ~ $ sudo su
sudo: unable to resolve host Gopal-pi2
root@Gopal-pi2:/home/pi# hostname Gopal-pi2
@rvgpl
rvgpl / what-forces-layout.md
Created February 22, 2016 11:31 — forked from paulirish/what-forces-layout.md
What forces layout/reflow. The comprehensive list.

What forces layout / reflow

All of the below properties or methods, when requested/called in JavaScript, will trigger the browser to synchronously calculate the style and layout*. This is also called reflow or layout thrashing, and is common performance bottleneck.

Element

Box metrics
  • elem.offsetLeft, elem.offsetTop, elem.offsetWidth, elem.offsetHeight, elem.offsetParent
  • elem.clientLeft, elem.clientTop, elem.clientWidth, elem.clientHeight
  • elem.getClientRects(), elem.getBoundingClientRect()
@rvgpl
rvgpl / gist:ce05854d1052dd62673f
Created February 25, 2016 11:16 — forked from jonathanmoore/gist:2640302
Get the share counts from various APIs

Share Counts

I have always struggled with getting all the various share buttons from Facebook, Twitter, Google Plus, Pinterest, etc to align correctly and to not look like a tacky explosion of buttons. Seeing a number of sites rolling their own share buttons with counts, for example The Next Web I decided to look into the various APIs on how to simply return the share count.

If you want to roll up all of these into a single jQuery plugin check out Sharrre

Many of these API calls and methods are undocumented, so anticipate that they will change in the future. Also, if you are planning on rolling these out across a site I would recommend creating a simple endpoint that periodically caches results from all of the APIs so that you are not overloading the services will requests.

Twitter

@rvgpl
rvgpl / meta-tags.html
Created April 22, 2016 05:22
Meta tags for nice mobile experience
<!-- Chrome, Firefox OS, Opera and Vivaldi status bar color -->
<meta name="theme-color" content="#FF00FF">
<!-- Windows Phone color-->
<meta name="msapplication-navbutton-color" content="#FF00FF">
<!-- iOS Safari color -->
<meta name="apple-mobile-web-app-status-bar-style" content="#ff00ff">
<!-- windows Phone tiles -->
<meta name="msapplication-TileColor" content="#ff0000">
<meta name="msapplication-TileImage" content="/mstile-144x144.png">
<!-- Don't use full screen on iOS -->

SCSS Style Guide

A guide to developing robust stylesheets in SCSS - based on SMACSS

Core goals of SMACSS:

  • Increase the semantic value of a section of html and content
  • Decrease the expectation of a specific html structure
<!DOCTYPE html>
<html >
<head>
<meta charset="UTF-8">
<title>Count Down</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.1.0/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/flipclock/0.7.8/flipclock.min.js"></script>
<style>
.flip-clock-wrapper {
<!DOCTYPE html>
<html >
<head>
<meta charset="UTF-8">
<title>Select State</title>
<style>
.select-state-container {
margin: 10px auto;
width: 300px;
}
<!DOCTYPE html>
<html >
<head>
<meta charset="UTF-8">
<title>Select State</title>
<style>
.select-state-container {
margin: 10px auto;
width: 300px;
}
<!DOCTYPE html>
<html >
<head>
<meta charset="UTF-8">
<title>Create a New Pen</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<style>.subscribe-form {
width: 100%;
overflow: hidden;
vertical-align: bottom;