Skip to content

Instantly share code, notes, and snippets.

Avatar
💭
I may be slow to respond.

Dost Muhammad Shah dmsherazi

💭
I may be slow to respond.
View GitHub Profile
@dmsherazi
dmsherazi / AVRRelay485.cpp
Last active Jan 4, 2016
fixed timer 0 issue
View AVRRelay485.cpp
#define F_CPU 8000000U
#include <avr/io.h>
#include <avr/interrupt.h>
#include <inttypes.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <util/delay.h>
#include <avr/eeprom.h>
const char slashr[]="\r";
View php
<html>
<head>
<title>Power comparator</title>
<script type="text/javascript" src="https://www.google.com/jsapi"></script>
<script type="text/javascript">
google.load("visualization", "1", {packages:["corechart"]});
google.setOnLoadCallback(drawChart);
function drawChart() {
var data = google.visualization.arrayToDataTable([
View colors.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="red_50">#fde0dc</color>
<color name="red_100">#f9bdbb</color>
<color name="red_200">#f69988</color>
<color name="red_300">#f36c60</color>
<color name="red_400">#e84e40</color>
<color name="red_500">#e51c23</color>
View UNIX timestamp to seconds, minutes, hours, days, weeks, month, years, decades ago.java
public static String caluculateTimeAgo(long timeStamp) {
long timeDiffernce;
long unixTime = System.currentTimeMillis() / 1000L; //get current time in seconds.
int j;
String[] periods = {"s", "m", "h", "d", "w", "m", "y", "d"};
// you may choose to write full time intervals like seconds, minutes, days and so on
double[] lengths = {60, 60, 24, 7, 4.35, 12, 10};
timeDiffernce = unixTime - timeStamp;
String tense = "ago";
View gist:aad7242969bd5e8f4d66
<receiver android:enabled="true" android:name=".BootUpReceiver"
android:permission="android.permission.RECEIVE_BOOT_COMPLETED">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</receiver>
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
View BootUpReceiver.java
public class BootUpReceiver extends BroadcastReceiver{
@Override
public void onReceive(Context context, Intent intent) {
Intent i = new Intent(context, MyActivity.class);
i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(i);
}
}
View mysql_countries.sql
/**
* Continents and Countries MySQL Tables compiled from Wikipedia, Braintree Payments documentation
* and a couple other places I don't recall at the moment. This data is compatible with the Braintree
* Payment API as of Dec 2011
*
* Compiled by Steve Kamerman, 2011
*/
SET FOREIGN_KEY_CHECKS=0;
-- ----------------------------
@dmsherazi
dmsherazi / sim900.mdown
Created Nov 23, 2015 — forked from tegila/sim900.mdown
SIM900 TIPS AND TRICKS
View sim900.mdown

TUTORIAL

Attach to GPRS Service

-> AT+CGATT = 1
<- OK

Define PDP Context (cid, PDP type, APN)

-> AT+CGDCONT=1,"IP","zap.vivo.com.br"
@dmsherazi
dmsherazi / SimpleMqttClient.java
Created Feb 23, 2016 — forked from m2mIO-gister/SimpleMqttClient.java
Example MQTT Messaging in Java
View SimpleMqttClient.java
import org.eclipse.paho.client.mqttv3.MqttCallback;
import org.eclipse.paho.client.mqttv3.MqttClient;
import org.eclipse.paho.client.mqttv3.MqttConnectOptions;
import org.eclipse.paho.client.mqttv3.MqttDeliveryToken;
import org.eclipse.paho.client.mqttv3.MqttException;
import org.eclipse.paho.client.mqttv3.MqttMessage;
import org.eclipse.paho.client.mqttv3.MqttTopic;
public class SimpleMqttClient implements MqttCallback {
@dmsherazi
dmsherazi / Schema.php
Created Apr 11, 2016 — forked from tournasdim/Schema.php
A list of Laravel's Schema commands (Laravel 4)
View Schema.php
<?php
Schema::create('users' , function($table)
{
$table->increments('id'); Incrementing ID to the table (primary key).
$table->string('email'); VARCHAR equivalent column
$table->string('name', 100); VARCHAR equivalent with a length
$table->integer('votes'); INTEGER equivalent to the table