Skip to content

Instantly share code, notes, and snippets.

Avatar
👨‍💻
Coding

Jorge Frisancho teocci

👨‍💻
Coding
View GitHub Profile
View log_battery_status.py
import android
import time
from datetime import date, datetime
def log_battery_status(droid):
"""Log battery percentage"""
droid.batteryStartMonitoring()
battery = 0
while not battery:
battery = droid.batteryGetLevel().result
@teocci
teocci / RecordingVideo.js
Created Apr 11, 2016 — forked from dawsontoth/RecordingVideo.js
How to record video, then share or save it. Using Appcelerator Titanium!
View RecordingVideo.js
/**
* This sample lets you record and share video with Appcelerator Titanium on Android.
* REQUIRES THE 1.6.0 RC OF TITANIUM MOBILE SDK
* http://developer.appcelerator.com/blog/2011/02/release-candidate-for-titanium-mobile-1-6-0.html
*/
/**
* First, create our UI. We'll have two buttons: record, and share.
*/
var win = Titanium.UI.createWindow({
@teocci
teocci / GITMigrator
Last active Apr 28, 2016
Proces to migrate a Forket Project from Eclipse to Android Studio and then update the git repo with the new Android Studio repo.
View GITMigrator
Move to the new repo Directory
cd newrepo
Add all the files to be commited
git --git-dir=/path/to/my/oldrepo/.git/ --work-tree=/path/to/my/newrepo/ add .
Commit the changes
git --git-dir=/path/to/my/oldrepo/.git/ --work-tree=/path/to/my/newrepo/ commit -a -m "This is the Android Studio version"
Add the remote origin
@teocci
teocci / GITMigrator
Created Apr 28, 2016
Proces to migrate a Forket Project from Eclipse to Android Studio and then update the git repo with the new Android Studio repo.
View GITMigrator
Move to the new repo Directory
cd newrepo
Add all the files to be commited
git --git-dir=/path/to/my/oldrepo/.git/ --work-tree=/path/to/my/newrepo/ add .
Commit the changes
git --git-dir=/path/to/my/oldrepo/.git/ --work-tree=/path/to/my/newrepo/ commit -a -m "This is the Android Studio version"
Add the remote origin
View GitIgnore Filer For android projects
# Built application files
/*/build
# Crashlytics configuations
com_crashlytics_export_strings.xml
# Local configuration file (sdk path, etc)
local.properties
# Gradle generated files
@teocci
teocci / The Other Road Ahead
Created May 11, 2016
Paul Graham, "Hackers and Painters", chapter 5: «The Other Road Ahead»
View The Other Road Ahead
http://paulgraham.com/road.html
View MediaRecorderExample.java
MediaRecorder mediaRecorder = new MediaRecorder();
CamcorderProfile profile = CamcorderProfile.get(CamcorderProfile.QUALITY_HIGH);
profile.videoFrameWidth = 1280;
profile.videoFrameHeight = 720;
mediaRecorder.setCamera(Camera.open());
mediaRecorder.setAudioSource(MediaRecorder.AudioSource.DEFAULT);
mediaRecorder.setVideoSource(MediaRecorder.VideoSource.CAMERA);
mediaRecorder.setProfile(profile);
@teocci
teocci / MVCMusicStore.md
Last active Jun 2, 2016
This is a tutorial application that introduces and explains step-by-step how to use ASP.NET MVC and Visual Studio for web development.
View MVCMusicStore.md

MVC Music Store

This is a tutorial application that introduces and explains step-by-step how to use ASP.NET MVC and Visual Studio for web development.

The MVC Music Store is a lightweight sample store implementation which sells music albums online, and implements basic site administration, user sign-in, and shopping cart functionality.

This tutorial series details all of the steps taken to build the ASP.NET MVC Music Store sample application. Part 8 covers Shopping Cart with Ajax Updates. We’ll allow users to place albums in their cart without registering, but they’ll need to register as guests to complete checkout. The shopping and checkout process will be separated into two controllers: a ShoppingCart Controller which allows anonymously adding items to a cart, and a Checkout Controller which handles the checkout process. We’ll start with the Shopping Cart in this section, then build the Checkout process in the following section.

Adding the Cart, Order, and OrderDetail model classes

@teocci
teocci / PersistingDataWithTempData.md
Last active Jun 2, 2016
TempData is used to pass data from current request to subsequent request.
View PersistingDataWithTempData.md

Persisting Data with TempData

TempData is used to pass data from current request to subsequent request, this means redirecting from one page to another. It’s life is very short and lies only till the target view is fully loaded. But you can persist data in TempData by calling Keep() method.

TempData with Keep method

If you want to keep value in TempData object after request completion, you need to call Keep method with in the current action. There are two overloaded Keep methods to retains value after current request completion.

void Keep()

Calling this method with in the current action ensures that all the items in TempData are not removed at the end of the current request.

@model MyProject.Models.EmpModel;
@{ 
View SessionVariablesASObjects.md

Session Variables as Objects

Or you could think of this as session objects. Either way the end result is the same. Everyone uses session variables at some point in their career. What I am doing is offering what I feel is a better way to deal with session variables.

When I have used session variables in the past I had two main issues; having to remember names and converting them when they were other than string. Not to mention using Session["SomeName"] was just too much typing without intellisense. Some people have wrapped their session variables with getters and setters. That is a nice idea, but still a bit too much work for what I want to do. After all I want my code to work for me, not just work. What if we save a class as a session object, and have the class save itself seamlessly as a session variable. This works great because you access the class thus giving you intellisense, strongly typed variables and you don't need to worry about checking the session since it is all in the class.

To dem