Skip to content

Instantly share code, notes, and snippets.

Avatar

James Hovious JamesHovious

View GitHub Profile
@JamesHovious
JamesHovious / Android SQLite.java
Last active Oct 24, 2018
A simple example of creating a SQLIte DB in Android.
View Android SQLite.java
package com.e3h.usmcknowledge.database;
import android.content.ContentValues;
import android.content.Context;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
public class DatabaseHelper {
@JamesHovious
JamesHovious / JulianDate.ps1
Last active Dec 6, 2021
PowerShell function to get today's Julian Date
View JulianDate.ps1
#Calculate today's julian date
$Year = get-date -format yy
$JulianYear = $Year.Substring(1)
$DayOfYear = (Get-Date).DayofYear
$JulianDate = $JulianYear + "{0:D3}" -f $DayOfYear
Write-Host $JulianDate
@JamesHovious
JamesHovious / JulianDate.java
Last active Nov 5, 2018
Output the Julian Date in Java
View JulianDate.java
private String jd(){
GregorianCalendar gc = new GregorianCalendar();
String year = new Integer(gc.get(GregorianCalendar.YEAR)).toString();
String jdPrefix = year.substring(3);
int jdSuffixInt = gc.get(GregorianCalendar.DAY_OF_YEAR);
String jdSuffix = String.format("%03d", jdSuffixInt);
String jd = jdPrefix + jdSuffix;
return jd;
}
View PlayNow.java
/*
* This class is a simple example showing a real world example of using AsyncTask to run a Network Thread.
* Nonrelevant is cut out in order to highlight the stucture of this class.
*/
public class PlayNowActivity extends Activity {
RelativeLayout btnNewGame, btnLoad;
@Override
public void onCreate(Bundle savedInstanceState) {
View MainActivity.java
package com.example.webview.hellloworld;
import android.app.Activity;
import android.app.ProgressDialog;
import android.os.Bundle;
import android.view.Window;
import android.webkit.WebChromeClient;
import android.webkit.WebView;
import android.webkit.WebViewClient;
@JamesHovious
JamesHovious / commands.ps1
Last active Feb 10, 2016
grep for ip addresses w/ regex
View commands.ps1
function encode_base64($string)
{
$string_bytes = [System.Text.Encoding]::Unicode.GetBytes($string)
return [System.Convert]::ToBase64String($string_bytes)
}
function decode_base64($base64)
{
$base_bytes = [System.Convert]::FromBase64String($base64)
return [System.Text.Encoding]::Unicode.GetString([char[]]$base_bytes)
View function_timer.py
def timer(f):
"""
Decorator to time the execution of a function
:param f: The function to be timed
:return: The time in seconds that it took for the function to execute
"""
def timing_function():
ts = time()
f()
te = time()
View rc.local
_IP=$(hostname -I)
# Make device discoverable
hciconfig hci0 piscan
# Set device name
hciconfig hci0 name 'My IP is '"$_IP"
# Wait 30 seconds
sleep 30
View randomIcon.Dart
import 'dart:html';
import 'dart:math';
void main() {
var rand = new Random();
var randomIcon = querySelector('#randomIcon');
if (rand.nextBool()){
randomIcon.attributes['class'] = 'fa fa-android';
}else{
@JamesHovious
JamesHovious / Brython Hello.py
Last active Aug 29, 2015
Brython REST API Tutorial
View Brython Hello.py
# Copy just lines 7 and 8 into the Brython online editor to try it out.
# Copy all of this code into a browser to try it on your own machine
<script src="{{ STATIC_URL }}js/brython/brython.js" type="text/javascript"></script>
<body onload="brython()">
<script type="text/python">
from browser import document
document['main'] <= "Hello world !"
</script>