Threw everything out I've done in the past week and downloaded the Android Studio 3.0 studio so I can use Kotlin. Also the lack of Android docs in Kotlin doesn't matter because it'll prompt to convert any java code pasted in to Kotlin syntax.
Probably late but I'm loving the syntax.
[code]
package au.com.vocabank.vocabank.backend
import android.content.Context
import android.database.sqlite.SQLiteDatabase
import android.database.sqlite.SQLiteOpenHelper
import android.content.ContentValues
const val DATABASE_NAME = "vocabdb"
const val TABLE_NAME = "vocab"
const val DATABASE_VER = 1
class DatabaseHandler : SQLiteOpenHelper {
constructor(ctx: Context) : super(ctx, DATABASE_NAME, null, DATABASE_VER)
override fun onCreate(db: SQLiteDatabase?) {
val CREATE_VOCAB_TABLE = "CREATE TABLE $TABLE_NAME ( id INTEGER PRIMARY KEY, word TEXT, definition TEXT, phonetic TEXT)"
db?.execSQL(CREATE_VOCAB_TABLE)
}
override fun onUpgrade(db: SQLiteDatabase?, oldVersion: Int, newVersion: Int) {
db?.execSQL("DROP TABLE IF EXISTS " + TABLE_NAME)
onCreate(db)
}
fun addVocab(v: VocabItem) {
val db = this.writableDatabase
val vals = ContentValues()
vals.put("word", v.word)
vals.put("definition", v.definition)
vals.put("phonetic", v.phonetic)
db.insert(TABLE_NAME, null, vals)
db.close()
}
fun getVocabList(): ArrayList<VocabItem> {
val vocabList = ArrayList<VocabItem>()
val query = "SELECT * FROM " + TABLE_NAME
val db = this.writableDatabase
val cursor = db.rawQuery(query, null)
if (cursor.moveToFirst()) {
do {
val v = VocabItem(cursor.getInt(0),
cursor.getString(1),
cursor.getString(2))
v.phonetic = cursor.getString(3)
vocabList.add(v)
} while (cursor.moveToNext())
}
return vocabList
}
}[/code]
Kotlin is really awesome and the fact that you can use any Java library without any issues makes it even better.
Can you recommend me how can I start with Kotlin using Android Studio? I'm looking to develop a simple app to check it out
[QUOTE=gonzalolog;52261384]Can you recommend me how can I start with Kotlin using Android Studio? I'm looking to develop a simple app to check it out[/QUOTE]
The latest Android studio version should have everything you need to get started. Checkout the official Kotlin docs, they have some nice examples for setting up an initial project:
[url]https://kotlinlang.org/docs/tutorials/kotlin-android.html[/url]
The overall setup/development process is pretty much the same as with Java.
[QUOTE=Mega1mpact;52260293]What algorithm are you using for that?[/QUOTE]
That example's just basic boid flocking + steering towards a specific position vector, as well as multiplying the speed by a function of the distance to the position vector
Got some fancy new features. The most important one is that I can watch a file for changes, and transmit those changes to worker instances. This is most useful for updating shader code without having to restart everything.
[media]https://www.youtube.com/watch?v=DaFEP25hD50[/media]
[IMG]http://puu.sh/vZenr/8f0053939d.png[/IMG]
Got a nice little chat history working. Uses kind of a one sided ring buffer where you only insert stuff but never remove it and when you overrun the buffer it'll automatically wrap around and remove elements from the bottom so it literally behaves exactly like a chat history with a limited number of stored messages should.
Nothing special at all but just typing it down and seeing it work pretty much instantly was satisfying.
-snip-
I've played it and i've really loved, do you think you can add a settings panel with video options for low end devices? (Moto G4 plus, it runs with lag at 15fps and it's because it low power gpu)
Micromachines does it, like it changes the viewport size iirc to run at 720p
[vid]https://s1.webmshare.com/VJJ4Z.webm[/vid]
still working on this thing
riddled with bugs and weird shit. like the objects not going through the ground because we simplified and extremed the ground generation to reduce polys.
here's how I wrote the countdown
[code]
public class CountDownShower : MonoBehaviour {
public MeshFilter number;
public MeshCharacterHandler meshNumberHandler;
private readonly int numberIterations = 3;
public void doCountDown(float totalTime) {
number.gameObject.SetActive(true);
float timeForEach = totalTime / numberIterations;
Tweener lastTweener = null;
for (int i = 0; i < numberIterations; i++) {
Tweener current = showNumber(numberIterations - i, timeForEach);
if(lastTweener != null) {
lastTweener.OnComplete(() => {
current.Play(); }
);
}
else {
current.Play(); // it's the first tween, fire
}
lastTweener = current;
}
}
private Tweener showNumber(int number, float time) {
var t = this.number.gameObject.transform;
// set up a tween that starts the scale to 0 and sets the number, then gradually goes to scale 1
float overshoot = 1.15f;
var tween = t.DOBlendableScaleBy(Vector3.one, time).SetEase(Ease.OutElastic, overshoot).OnPlay( () => {
t.localScale = Vector3.zero;
this.number.mesh = meshNumberHandler.getNumberMesh(number);
});
tween.Pause();
return tween;
}
}[/code]
[QUOTE=DrDevil;52264462]Got some fancy new features. The most important one is that I can watch a file for changes, and transmit those changes to worker instances. This is most useful for updating shader code without having to restart everything.
[media]https://www.youtube.com/watch?v=DaFEP25hD50[/media][/QUOTE]
[url=https://youtu.be/M-aDSLIE66w?list=PLCFB4C710142835A1]I thought nobody in this world had actually played gish, let alone had its OST on a playlist[/url]
-snip-
So I got accepted to work on the job a few days back. One of the other project members turned out to be a facepuncher as well, which was a surprise. It seems like we're rampant
I wish I could talk about it, because the project can be described as 'really very awesome'
Edit:
Its a job for money and everything
Nice dude! Congrats!
[QUOTE=JohnnyOnFlame;52266620][url=https://youtu.be/M-aDSLIE66w?list=PLCFB4C710142835A1]I thought nobody in this world had actually played gish, let alone had its OST on a playlist[/url][/QUOTE]
Someone posted a gish like thing 2 pages ago and it reminded me of gish, so I looked up the OST and came across the original [url]https://www.youtube.com/watch?v=romVeYGa5CI[/url]
That band is fucking sick, I highly recommend listening to their other music aswell. 'The Silent Elk of Yesterday' will also be familiar.
[QUOTE=Icedshot;52267556]So I got accepted to work on the job a few days back. One of the other project members turned out to be a facepuncher as well, which was a surprise. It seems like we're rampant
I wish I could talk about it, because the project can be described as 'really very awesome'
Edit:
Its a job for money and everything[/QUOTE]
That's great!
Reminds me that when I got this job a year ago I was surprised to find a facepuncher as a coworker as well. A mod, even. :v:
Got awarded a project on freelancer, guy needed help setting up some temperature sensors with his Raspberry Pi to send email notifications
Finished it in pretty much no time
[IMG]http://i.imgur.com/5IE6fdo.png[/IMG]
and finally my freelancer balance is out of the negatives!
[QUOTE=cody1111;52269671]Got awarded a project on freelancer, guy needed help setting up some temperature sensors with his Raspberry Pi to send email notifications
Finished it in pretty much no time
[IMG]http://i.imgur.com/5IE6fdo.png[/IMG]
and finally my freelancer balance is out of the negatives![/QUOTE]
Why would he want the master bedroom to be warm? Its almost impossible to sleep when its too warm, even if only slightly.
[QUOTE=James xX;52270337]Why would he want the master bedroom to be warm? Its almost impossible to sleep when its too warm, even if only slightly.[/QUOTE]
Either it's 62 real degrees and it's fucking misery, it's kelvin and he's frozen or it's just burger units and a lovely 16 real degrees.
[QUOTE=James xX;52270337]Why would he want the master bedroom to be warm? Its almost impossible to sleep when its too warm, even if only slightly.[/QUOTE]
It's probably Fahrenheit. I keep my second floor AC at 70. And it looks like those are his Max and min values.
[QUOTE=James xX;52270337]Why would he want the master bedroom to be warm? Its almost impossible to sleep when its too warm, even if only slightly.[/QUOTE]
I used random numbers for debugging :) Not sure what he's even really using the temp sensors for
Simple class to provide UDP networking through the LAN. It works almost identically to garrysmod net, enjoy. Examples are in the Program.cs.
[url]https://github.com/Bambofy/LANHelper[/url]
See some more stuff here: [url]http://richardbamford.blogspot.co.uk/2017/05/recovery-programming.html[/url]
[QUOTE=Perl;52268710]That's great!
Reminds me that when I got this job a year ago I was surprised to find a facepuncher as a coworker as well. A mod, even. :v:[/QUOTE]
What a coincidence, this happened to layla and ziks too!
[QUOTE=Bambo.;52272834]Simple class to provide UDP networking through the LAN. It works almost identically to garrysmod net, enjoy. Examples are in the Program.cs.
[url]https://github.com/Bambofy/LANHelper[/url]
See some more stuff here: [url]http://richardbamford.blogspot.co.uk/2017/05/recovery-programming.html[/url][/QUOTE]
Given you are supplying the type when reading from the buffer, you needn't send the length of each data. You could instead deduce it from the type returned, except for strings maybe unless you are fine null terminating them.
[QUOTE=James xX;52273088]Given you are supplying the type when reading from the buffer, you needn't send the length of each data. You could instead deduce it from the type returned, except for strings maybe unless you are fine null terminating them.[/QUOTE]
Oh yeah! That makes sense, thanks.
Edit:
No wait that's not true because it's not the length of the type that i'm sending it's the number of elements in the array that was sent.
[QUOTE=Bambo.;52273191]Oh yeah! That makes sense, thanks.
Edit:
No wait that's not true because it's not the length of the type that i'm sending it's the number of elements in the array that was sent.[/QUOTE]
My bad.
So for some reason MS [URL="https://developercommunity.visualstudio.com/content/problem/59359/profile-guided-optimization-broken-in-vs2017.html"]changed the paths of the various tools binaries, including Profile Guided Optimization[/URL], with VS2017. Not sure why they didn't bother fixing the paths in the compiler/project Include macros that usually grab everything you need though. So I spent quite some trying to figure this out, as I wanted to see if a PGO run would clear up some bottlenecks I had from a terrifyingly large and unavoidable if-else if-else statement (it did).
I've got my slicer ready to generate GCode output now - after spending a number of days on a really retarded bug. Whenever I looked at the final output from my perimeter generator (takes 2D profiles and generates the N looping inset paths that make the outer skin of a 3D print) I noticed that the paths [I]never[/I] closed and there was always a gap. So I searched up and down and through my perimeter code to find the source of the error, as it only occured in the perimeter step. Nothing worked, so I started outputting SVGs from each stage and sub-method of my perimeter slicer. I did that for a few hours yesterday until I realized [I][B]holy fuck im dumb[/B][/I]
The fact that the paths never closed was the key part - it always happened at the end of a given loop, and was more consistent than a bug with the toolpath generation itself would've been. So, the problem was that perimeters didn't automatically set their very last point as a copy of the first point, thus the SVG utility I had drew an incomplete loop since it never got the last point it needed to complete the polygon. The fix for my nearly week-long frustrating experience was as simple as this in my SVG writer:
[cpp]
transformed = transform(polyline[0]);
fprintf(out, "L%lli,%lli", transformed.X, transformed.Y);
[/cpp]
[I]goddamnit[/I]. A week of being stuck on a bug that was a bug (more just like a mistake outright) in my scant debugging utilities. [URL="http://fuchstraumer.github.io/final_layer_1.html"]The generated output looks fairly neat though.[/URL] I always liked seeing the insides of my prints for the sake of interesting/satisfying infill patterns
[QUOTE=Radical_ed;52260161]Made a little web demo if anyone wanted to try it out
(warning- might run like shit due to JS weirdness. Runs a [I]lot[/I] better in firefox)
[url]https://sks-studios.itch.io/swarming-demo[/url][/QUOTE]
I've massively improved the speed of the spatial partition, and it now allocates 0b to GC when in use. I have to finish unit tests but it's looking like a truly log(n) (or better) operation for all steps involving NN searches, because I don't need to re-balance the tree after removing elements.
[img]https://my.mixtape.moe/izqnck.gif[/img]
PS- if anyone has experience with pinned pointers in c#, I'd love to know if there is a better way to do this
[code]
/// <summary>
/// Configures leaf l as a child of
/// the parent leaf pl.
/// </summary>
/// <param name="pl">parent leaf ref</param>
/// <param name="ci">child index of l on pl</param>
/// <param name="l">leaf being configured as child of pl</param>
private static unsafe void ConfigureLeaf(ref Leaf pl, int ci, ref Leaf l)
{
// reset child fields (data not cleaned when reinserted to table)
l.StateFlag = 0;
l.NumPoints = 0;
l.NodeLevel = (byte)(pl.NodeLevel + 1);
l.ParentIndex = pl.LeafIndex;
l.Extents = pl.Extents / 2;
// Set midpoint of child leaf
fixed (float* xBuf = pl.Bounds_X) l.MidPoint.x = (xBuf[ci] + pl.MidPoint.x) / 2;
fixed (float* yBuf = pl.Bounds_Y) l.MidPoint.y = (yBuf[ci] + pl.MidPoint.y) / 2;
// Set XY of bounds of child leaf
fixed (float* xBuf = l.Bounds_X)
{
xBuf[0] = (l.MidPoint.x - l.Extents);
xBuf[1] = (l.MidPoint.x + l.Extents);
xBuf[2] = (l.MidPoint.x - l.Extents);
xBuf[3] = (l.MidPoint.x + l.Extents);
}
fixed (float* yBuf = l.Bounds_Y)
{
yBuf[0] = (l.MidPoint.y + l.Extents);
yBuf[1] = (l.MidPoint.y + l.Extents);
yBuf[2] = (l.MidPoint.y - l.Extents);
yBuf[3] = (l.MidPoint.y - l.Extents);
}
fixed (ushort* cBuf = pl.Children)
{
cBuf[ci] = l.LeafIndex;
}
}
[/code]
[QUOTE=Radical_ed;52274966]PS- if anyone has experience with pinned pointers in c#, I'd love to know if there is a better way to do this
[code]
/// <summary>
/// Configures leaf l as a child of
/// the parent leaf pl.
/// </summary>
/// <param name="pl">parent leaf ref</param>
/// <param name="ci">child index of l on pl</param>
/// <param name="l">leaf being configured as child of pl</param>
private static unsafe void ConfigureLeaf(ref Leaf pl, int ci, ref Leaf l)
{
// reset child fields (data not cleaned when reinserted to table)
l.StateFlag = 0;
l.NumPoints = 0;
l.NodeLevel = (byte)(pl.NodeLevel + 1);
l.ParentIndex = pl.LeafIndex;
l.Extents = pl.Extents / 2;
// Set midpoint of child leaf
fixed (float* xBuf = pl.Bounds_X) l.MidPoint.x = (xBuf[ci] + pl.MidPoint.x) / 2;
fixed (float* yBuf = pl.Bounds_Y) l.MidPoint.y = (yBuf[ci] + pl.MidPoint.y) / 2;
// Set XY of bounds of child leaf
fixed (float* xBuf = l.Bounds_X)
{
xBuf[0] = (l.MidPoint.x - l.Extents);
xBuf[1] = (l.MidPoint.x + l.Extents);
xBuf[2] = (l.MidPoint.x - l.Extents);
xBuf[3] = (l.MidPoint.x + l.Extents);
}
fixed (float* yBuf = l.Bounds_Y)
{
yBuf[0] = (l.MidPoint.y + l.Extents);
yBuf[1] = (l.MidPoint.y + l.Extents);
yBuf[2] = (l.MidPoint.y - l.Extents);
yBuf[3] = (l.MidPoint.y - l.Extents);
}
fixed (ushort* cBuf = pl.Children)
{
cBuf[ci] = l.LeafIndex;
}
}
[/code][/QUOTE]
What are the types of Bounds_X, Bounds_Y, Children? Seeing as you don't do any casts, it has to be your generic float[] and ushort[], but why are you using the fixed statement then?
[QUOTE=cartman300;52275572]What are the types of Bounds_X, Bounds_Y, Children? Seeing as you don't do any casts, it has to be your generic float[] and ushort[], but why are you using the fixed statement then?[/QUOTE]
Array allocation on stack instead of heap
Sorry, you need to Log In to post a reply to this thread.