Skip to content

Instantly share code, notes, and snippets.

View sorianog's full-sized avatar
📱
Honing my Android skills

Gerald sorianog

📱
Honing my Android skills
View GitHub Profile
@sorianog
sorianog / WidgetWithAccelerometer.kt
Created March 7, 2022 09:24 — forked from PSPanishetti/WidgetWithAccelerometer.kt
Spaghetti code for working widget that attached to accelerometer in android.
import android.content.Context
import android.hardware.Sensor
import android.hardware.SensorEvent
import android.hardware.SensorEventListener
import android.hardware.SensorManager
import androidx.compose.animation.ExperimentalAnimationApi
import androidx.compose.animation.core.animateFloatAsState
import androidx.compose.foundation.Image
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.*
// Source https://blog.gradle.org/jcenter-shutdown
// In app/module gradle file, do the following
...
repositories {
mavenCentral()
jcenter {
content {
// org.jetbrains.trove4j is only available in JCenter
includeGroup("org.jetbrains.trove4j")
/*
* Input: n, number of type Int
* Range: 1 to n (inclusive)
*
* If i is multiple of 3 & 5, print "FizzBuzz"
* If i is multiple of 3 only, print "Fizz"
* If i is multiple of 5 only, print "Buzz"
* If i is not multiple of any (above), print value of i
*
*/

Interview Questions

Kotlin

Q1: What is a primary constructor in Kotlin? ☆☆

Answer: The primary constructor is part of the class header. Unlike Java, you don't need to declare a constructor in the body of the class. Here's an example:

@sorianog
sorianog / trxer-format-exception
Created March 2, 2017 16:38
FormatException occurred when running trxer
Unhandled Exception: System.FormatException: String was not recognized as a vali
d DateTime.
at System.DateTimeParse.Parse(String s, DateTimeFormatInfo dtfi, DateTimeStyl
es styles)
at System.DateTime.Parse(String s)
at System.Xml.Xsl.CompiledQuery.Script1.GetShortDateTime(String time) in c:\T
emp\y31uys5o.0.cs:line 47
at System.Xml.Xsl.CompiledQuery.Query.<xsl:template name="tDetails">(XmlQuery
Runtime {urn:schemas-microsoft-com:xslt-debug}runtime, XPathNavigator {urn:schem
as-microsoft-com:xslt-debug}current, Double {urn:schemas-microsoft-com:xslt-debu
{
"ver":"6.9.3.0",
"nv":0,
"sv":0,
"extURL":"chrome-extension://abjcfabbhafbcdfjoecdgepllmpfceif/",
"uid":"c51d8b27-7827-40b3-a798-59e6ce52cb38",
"mwvc":true,
"color":"yellow",
"mwvct":0,
"mwvci":2,
<!-- START: Livefyre Embed -->
<div id="livefyre-comments"></div>
<script type="text/javascript" src="http://zor.livefyre.com/wjs/v3.0/javascripts/livefyre.js"></script>
<script type="text/javascript">
(function () {
var articleId = fyre.conv.load.makeArticleId(null);
fyre.conv.load({}, [{
el: 'livefyre-comments',
network: "livefyre.com",
siteId: "379401",
@sorianog
sorianog / goog-analytics-ghost.js
Last active February 1, 2017 05:31
Tracking script for Google Analytics on a blog powered by Ghost from http://academy.ghost.org/how-to-monitor-your-ghost-blogs-traffic/
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-XXXXXXXX-X', 'blog.name.here');
ga('send', 'pageview');
</script>