Skip to content

Instantly share code, notes, and snippets.

View MillerAdulu's full-sized avatar
💭
I will be slow to respond.

Miller Adulu MillerAdulu

💭
I will be slow to respond.
View GitHub Profile

Introduction to Python

Visit: bit.do/websec-gist for links to resources


Variables

  • Variables are containers for storing data values.
@MillerAdulu
MillerAdulu / jwttoobject.dart
Last active December 2, 2019 08:57
Decodes a JWT and returns results as a map
mixin JWTToObject {
Map<String, dynamic> parseJwt(String token) {
final parts = token.split('.');
if (parts.length != 3) {
throw Exception('invalid token');
}
final payload = _decodeBase64(parts[1]);
final payloadMap = json.decode(payload);
if (payloadMap is! Map<String, dynamic>) {
@MillerAdulu
MillerAdulu / main.dart
Created December 31, 2019 21:13
Dynamic Generation of Form Fields Based on Database Values
// Assumption is, all the fields hold the same kind of value
// An entry from the database together with the ID
class Measurement {
final int id;
final String name;
Measurement({this.id, this.name});
}
// Field Instance class defines the variables that will be used for each field
class FieldInstance {
@MillerAdulu
MillerAdulu / (Child) MemberDeposit.php
Last active April 15, 2020 19:03
Seed data with foreign keys
<?php
use Faker\Generator as Faker;
use App\Member;
$factory->define(App\MemberDeposit::class, function (Faker $faker) {
$members = Member::all()->pluck('member_id')->toArray();
return [
'member_id' => $faker->randomElement($members),
@MillerAdulu
MillerAdulu / shopping_cart.dart
Last active July 10, 2020 10:12 — forked from simolus3/shopping_cart.dart
Shopping carts in moor
import 'package:moor/moor.dart';
import 'package:rxdart/rxdart.dart';
part 'shopping_cart.g.dart';
class ShoppingCarts extends Table {
IntColumn get id => integer().autoIncrement()();
}
class BuyableItems extends Table {
@MillerAdulu
MillerAdulu / digitalocean.md
Created October 27, 2020 16:38 — forked from cole007/digitalocean.md
Digital Ocean internal migration - moving files between droplets over SSH/SCP

If you need to move a lot of files between DO server you can move these through SCP over the internal private Digital Ocean network.

NB both droplets need to be within the same region

To do this you need:

  1. enable private network for each droplet (if not done at creation, note the droplet needs to be off for this to be enabled once live)
  2. ensure that eth1 is enabled for both droplets if not already - see https://www.digitalocean.com/community/tutorials/how-to-enable-digitalocean-private-networking-on-existing-droplets
  3. scp files from the source server to the destination server are sent like:
@MillerAdulu
MillerAdulu / pivot-tables.md
Created March 24, 2021 14:39 — forked from Braunson/pivot-tables.md
Laravel 8.x - Diving into Pivot Tables

Laravel 6 - Diving Into Pivot Tables

Pivot tables can be confusing and a little hard to wrap your head around at first. In this quick article we are going to dive into what a pivot table is, how to create one and finally how to use the pivot table. Let's dive in!

What is a pivot table?

A pivot table is used to connect relationships between two tables. Laravel provides a Many To Many relationship where you can use a pivot table.

@MillerAdulu
MillerAdulu / chunk_list_sample.dart
Created October 16, 2021 13:39 — forked from jorwan/chunk_list_sample.dart
Extension to chunk list
void main() => print(List.generate(10, (i) => i).chunk(3));
extension ListChunkerExtension on List {
List chunk(int chunkLength) {
if ((chunkLength ?? 0) <= 0 || (this ?? []).length == 0)
return this;
var chunks = [];
for (var i = 0; i < this.length; i += chunkLength) {
chunks.add(this.sublist(
i, i + chunkLength > this.length ? this.length : i + chunkLength));
on:
pull_request:
types: [closed]
branches:
- master
jobs:
docker:
runs-on: ubuntu-latest
if: github.event.pull_request.merged
steps:
@MillerAdulu
MillerAdulu / workflow.yaml
Created August 19, 2023 12:32
Create a file on the fly
- name: Create .env
run: |
echo "API_KEY_WEB=${{ secrets.API_KEY_WEB }}" >> .env
echo "API_KEY_ANDROID=${{ secrets.API_KEY_ANDROID }}" >> .env
# What this will do is that it will get the key from the secrets in the repository and push
# then into the .env file before you can build your APK or project