Skip to content

Instantly share code, notes, and snippets.

View chayanforyou's full-sized avatar
🤖
Learning

Chayan Mistry chayanforyou

🤖
Learning
View GitHub Profile
@igniteflow
igniteflow / rename.py
Created September 19, 2011 16:41
Python script to rename files in directory, transforming spaces to hyphens and the chars to lowercase
import os
"""
Renames the filenames within the same directory to be Unix friendly
(1) Changes spaces to hyphens
(2) Makes lowercase (not a Unix requirement, just looks better ;)
Usage:
python rename.py
"""
@mkleemann
mkleemann / atmega8_timer0.c
Created January 2, 2012 20:52
atmega8 timer0 - use overflow interrupt
// All values/comments are valid with ATmega8 running at Fosc = 4.000MHz
#include <avr/io.h>
#include <avr/interrupt.h>
// TIMER0 with prescaler clkI/O/1024
#define TIMER0_PRESCALER (1 << CS02) | (1 << CS00)
void main()
@redteam-snippets
redteam-snippets / decimalToFraction.js
Created October 22, 2012 21:02
JavaScript: Decimal To Fraction
// Adapted from: http://bateru.com/news/2011/11/improved-code-for-javascript-decimal-to-fraction/
function gcd(a, b) {
return (b) ? gcd(b, a % b) : a;
}
var decimalToFraction = function (_decimal) {
var top = _decimal.toString().replace(/\d+[.]/, '');
var bottom = Math.pow(10, top.length);
if (_decimal > 1) {
@rajivnarayana
rajivnarayana / DrawableAlignedButton.java
Created March 22, 2013 21:26
Custom drawn Android button which aligns left drawable and its text to center.
package com.webileapps.myrtprofile;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.drawable.Drawable;
import android.util.AttributeSet;
import android.widget.Button;
/**
*
@jaffes2
jaffes2 / DecimalToFraction
Created June 28, 2013 04:21
Decimal to Fraction Converter
/*
* Converts Decimals to Fractions
*
*/
package simpleai;
/**
*
* @author sarabeth
*/
@StephanHoyer
StephanHoyer / github.js
Last active February 13, 2024 14:19
Commiting multiple files to github over API
'use strict';
var Octokat = require('octokat');
var extend = require('lodash/object/assign');
var defaults = {
branchName: 'master',
token: '',
username: '',
reponame: ''
@ryanamaral
ryanamaral / Arduino 230v Light bulb dimming
Last active November 23, 2020 18:46
Arduino 230v Light Bulb Dimming (Portugal 220V 50 Hz)
//source: http://electronics.stackexchange.com/q/59615
int AC_LOAD = 3; // Output to Opto Triac pin
int dimming = 128; // Dimming level (0-128) 0 = ON, 128 = OFF
void setup()
{
pinMode(AC_LOAD, OUTPUT); // Set the AC Load as output
attachInterrupt(0, zero_crosss_int, RISING); // Choose the zero cross interrupt # from the table above
}
@lephuongbg
lephuongbg / One (dark).kateschema
Created May 14, 2015 04:09
One (dark) - Kate Schema (ported from Atom.io editor theme)
[Default Item Styles - Schema One (dark)]
Alert=ffc7626b,ffc7626b,1,,,,fffae9eb,-,,---
Annotation=ff7f8c8d,ff7f8c8d,,,,,-,-,,---
Attribute=ffe5c17c,ffe5c17c,,,,,-,-,,---
Base-N Integer=ffe5c17c,ffe5c17c,,,,,-,-,,---
Built-in=ffabb2c0,ffabb2c0,,,,,-,-,,---
Character=ff97c378,ff97c378,,,,,-,-,,---
Comment=ff4f5562,ff4f5562,,,,,-,-,,---
Comment Variable=ff7f8c8d,ff7f8c8d,,,,,-,-,,---
Constant=ffabb2c0,ffabb2c0,1,,,,-,-,,---
@blackcj
blackcj / MainActivity.java
Last active October 9, 2022 09:52
Design support library with CoordinatorLayout, SwipeRefreshLayout and RecyclerView.
import android.os.Bundle;
import android.support.design.widget.AppBarLayout;
import android.support.design.widget.TabLayout;
import android.support.v4.widget.SwipeRefreshLayout;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.GridLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.util.Log;
import com.blackcj.designsupportexample.adapters.RecyclerViewAdapter;
@hrules6872
hrules6872 / TextViewDrawableSize.java
Last active September 8, 2022 12:22
TextViewDrawableSize - CompoundDrawable size
public class TextViewDrawableSize extends TextView {
private static final int DEFAULT_COMPOUND_DRAWABLE_SIZE = -1;
private int compoundDrawableWidth;
private int compoundDrawableHeight;
public TextViewDrawableSize(Context context) {
this(context, null);
}
public TextViewDrawableSize(Context context, AttributeSet attrs) {