Skip to content

Instantly share code, notes, and snippets.

View ademkocamaz's full-sized avatar

Adem KOCAMAZ ademkocamaz

View GitHub Profile
@OKatrych
OKatrych / ViewModels.kt
Created September 20, 2023 19:22
Composable scoped viewmodel
import androidx.compose.runtime.Composable
import androidx.compose.runtime.CompositionLocalProvider
import androidx.compose.runtime.RememberObserver
import androidx.compose.runtime.remember
import androidx.compose.runtime.saveable.rememberSaveable
import androidx.compose.ui.platform.LocalContext
import androidx.lifecycle.ViewModelStore
import androidx.lifecycle.ViewModelStoreOwner
import androidx.lifecycle.viewmodel.compose.LocalViewModelStoreOwner
import timber.log.Timber
@rchardptrsn
rchardptrsn / compose_sql_server.yaml
Last active June 19, 2024 08:44
Docker compose file for SQL Server 2022
services:
mssql:
container_name: mssql-db
hostname: mssql-db
image: mcr.microsoft.com/mssql/server:2022-latest
environment:
ACCEPT_EULA: 'Y'
MSSQL_SA_PASSWORD: 'Passw0rd'
MSSQL_DATA_DIR: /var/opt/mssql/data
@diyinfosec
diyinfosec / 01-aes-bruteforce.py
Created January 25, 2022 19:36
Brute-force AES-256 keys from memory dump.
from timeit import default_timer as timer
from binascii import b2a_hex
#- Config variables
filename="memory.dmp"
aes_key_size=32
#- Variables related to file processing
file_offset=0;
total_keys_found = 0;
@adamghill
adamghill / scorched_earth.sh
Last active September 25, 2023 18:08
Start from scratch for database migrations in Django
#!/bin/sh
set -e
die () {
echo >&2 "$@"
exit 1
}
[ "$#" -eq 1 ] || die "Database name argument is required"
@tkuenneth
tkuenneth / MainActivity.kt
Created May 29, 2021 10:07
How to display an adaptive icon in Jetpack Compose
package com.thomaskuenneth.sandbox
import android.graphics.Bitmap
import android.graphics.Canvas
import android.os.Bundle
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import androidx.compose.foundation.Image
import androidx.compose.foundation.layout.*
import androidx.compose.material.MaterialTheme
<?php
// Initilise cURL
$ch = curl_init();
// Set the cURL Options
$optArray = array(
CURLOPT_URL => 'https://example.com/api/getInfo/',
CURLOPT_RETURNTRANSFER => true
);
@jmorakuebler
jmorakuebler / get_field_verbose_name.py
Created November 13, 2019 13:11
Custom django template tag that returns the verbose name of a field.
from django.template import Library
register = Library()
@register.simple_tag
def get_field_verbose_name(instance, field_name):
"""Returns the verbose_name of the specified field."""
return instance._meta.get_field(field_name).verbose_name.title()
@lc-thomas
lc-thomas / admin.py
Last active September 25, 2023 22:15
Django custom admin site with list_display, tabular inline data, custom templates and custom view
from django.contrib import admin
from django.contrib.admin.models import LogEntry
from django.db.models import ManyToOneRel, ForeignKey, OneToOneField
from django.apps import apps
from django.contrib.auth.models import Group, User
from django.contrib.auth.admin import GroupAdmin, UserAdmin
from django.conf.urls import url
# admin custom views
from . import admin_views
@tiagoad
tiagoad / macos-pyodbc-freetds-mssql-django.md
Last active October 6, 2023 16:45
macOS Mojave + pyodbc + FreeTDS + SQL Server + Django 2.2

pyODBC + FreeTDS

  1. Run brew install unixodbc freetds
  2. Add section to /usr/local/etc/odbcinst.ini:
    [FreeTDS]
    Description     = FreeTDS unixODBC Driver
    Driver          = /usr/local/lib/libtdsodbc.0.so
    Setup           = /usr/local/lib/libtdsodbc.0.so
    UsageCount      = 1
@jjuanrivvera99
jjuanrivvera99 / mssql-docker-compose.yml
Last active June 20, 2024 17:32
SQL Server with Docker Compose
version: '3.3'
services:
mssql:
container_name: sql-server
image: mcr.microsoft.com/mssql/server:2017-latest
#image: mcr.microsoft.com/mssql/server:2017-CU11-ubuntu
restart: always
environment:
ACCEPT_EULA: "Y"