Skip to content

Instantly share code, notes, and snippets.

⁉️
I have no idea what I'm doing

Johann Pardanaud nesk

⁉️
I have no idea what I'm doing
Block or report user

Report or block nesk

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@nesk
nesk / .gitignore
Last active Jun 20, 2019
PHPUnit - Data providers memory showcase
View .gitignore
/vendor
composer.lock
@nesk
nesk / DefaultController.php
Created Nov 29, 2018
Report an exception with Symfony without throwing
View DefaultController.php
<?php
namespace App\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
use Symfony\Component\HttpFoundation\RequestStack;
use Symfony\Component\HttpKernel\Event\GetResponseForExceptionEvent;
use Symfony\Component\HttpKernel\HttpKernelInterface;
use Symfony\Component\HttpKernel\KernelEvents;
@nesk
nesk / MainActivity.kt
Last active Jun 26, 2018
Android pre-populated database (full)
View MainActivity.kt
package com.example.example
import android.os.Bundle
import android.support.v7.app.AppCompatActivity
class MainActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
@nesk
nesk / MyDatabaseHelper.kt
Last active Jun 26, 2018
Android pre-populated database (installing on read)
View MyDatabaseHelper.kt
package com.example.example
// ...
class ActsDbHelper(val context: Context) : SQLiteOpenHelper(context, DATABASE_NAME, null, DATABASE_VERSION) {
// private val preferences: SharedPreferences = ...
private fun installedDatabaseIsOutdated(): Boolean {
// ...
@nesk
nesk / MyDatabaseHelper.kt
Created Jun 26, 2018
Android pre-populated database (update methods)
View MyDatabaseHelper.kt
package com.example.example
// ...
import android.content.SharedPreferences
class ActsDbHelper(val context: Context) : SQLiteOpenHelper(context, DATABASE_NAME, null, DATABASE_VERSION) {
private val preferences: SharedPreferences = context.getSharedPreferences(
"${context.packageName}.database_versions",
Context.MODE_PRIVATE
@nesk
nesk / MyDatabaseHelper.kt
Last active Jun 26, 2018
Android pre-populated database (installation method)
View MyDatabaseHelper.kt
package com.example.example
// ...
import java.io.File
import java.io.FileOutputStream
class ActsDbHelper(val context: Context) : SQLiteOpenHelper(context, DATABASE_NAME, null, DATABASE_VERSION) {
private fun installDatabaseFromAssets() {
val inputStream = context.assets.open("$ASSETS_PATH/$DATABASE_NAME.sqlite3")
@nesk
nesk / MyDatabaseHelper.kt
Created Jun 25, 2018
Android pre-populated database (basic database helper)
View MyDatabaseHelper.kt
package com.example.example
import android.content.Context
import android.database.sqlite.SQLiteDatabase
import android.database.sqlite.SQLiteOpenHelper
class ActsDbHelper(val context: Context) : SQLiteOpenHelper(context, DATABASE_NAME, null, DATABASE_VERSION) {
override fun onCreate(db: SQLiteDatabase?) {
// Nothing to do
@nesk
nesk / metadata.sql
Created Jun 25, 2018
Android pre-populated database (android_metadata table)
View metadata.sql
CREATE TABLE android_metadata (locale TEXT);
INSERT INTO android_metadata VALUES ("en_US");
@nesk
nesk / mapping.js
Created Mar 16, 2018
Mapping objects in JavaScript (Object.fromEntries + pipeline operator)
View mapping.js
const data = {
a: 1,
b: 2,
};
const newData = Object.entries(data)
.map(([key, value]) => ({ [`_${key}`]: value + 1 }))
|> Object.fromEntries;
@nesk
nesk / mapping.js
Created Mar 16, 2018
Mapping objects in JavaScript (Object.fromEntries)
View mapping.js
const data = {
a: 1,
b: 2,
};
const newData = Object.fromEntries(
Object.entries(data)
.map(([key, value]) => ({ [`_${key}`]: value + 1 }))
);
You can’t perform that action at this time.