Skip to content

Instantly share code, notes, and snippets.

View lentiummmx's full-sized avatar

lentiummmx lentiummmx

View GitHub Profile
@bibarsov
bibarsov / AppConfig.java
Last active February 15, 2024 22:48
Spring / Hikari / Postgres / Multiple datasources
package test.app.config;
import com.zaxxer.hikari.HikariDataSource;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.jdbc.DataSourceBuilder;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.DependsOn;
import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate;
@a-recknagel
a-recknagel / .coveragerc
Created August 28, 2019 14:13
gitlab CI template
[run]
branch = True
source = my_django_lib
omit =
src/my_django_lib/settings.py
*/__init__.py
[paths]
source = src
@iamaziz
iamaziz / read_csv_files_in_tar_gz_from_s3_bucket.py
Last active November 22, 2022 14:45
Read csv files from tar.gz in S3 into pandas dataframes without untar or download (using with S3FS, tarfile, io, and pandas)
# -- read csv files from tar.gz in S3 with S3FS and tarfile (https://s3fs.readthedocs.io/en/latest/)
bucket = 'mybucket'
key = 'mycompressed_csv_files.tar.gz'
import s3fs
import tarfile
import io
import pandas as pd
@edudobay
edudobay / git-branch-protection.md
Last active June 27, 2023 13:02
Command-line script for protecting/unprotecting branches in a GitHub repository

(To be improved)

Requirements

  • httpie (which provides the http command) — pip install httpie

Setup

  • Save the git-branch-protection.sh as git-branch-protection somewhere in your path (something like ~/bin or ~/.local/bin if you already use it)
  • Generate a GitHub token and save it as ~/.config/github_token.
@tristansokol
tristansokol / linear-regression-tensorflow.html
Created June 30, 2018 03:53
linear regression with tensorflow
<script src="https://cdn.jsdelivr.net/npm/@tensorflow/tfjs@0.11.7"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.7.2/Chart.bundle.min.js"></script>
<div style="width:400px;">
<canvas id="myChart" width="400" height="400"></canvas>
</div>
<button onclick="train()">Train the model 1 step</button>
<script>
const trainX = [
3.3,
@Geekfish
Geekfish / patch_with_reload.py
Last active July 27, 2023 08:44
Same as patch, but allows you to pass a module object which will be reloaded when entering/leaving the context.
import imp
from functools import partial
from mock.mock import _patch, _get_target, DEFAULT
class PatchWithReload(_patch):
def __init__(self, module_to_reload, *args, **kwargs):
self.module_to_reload = module_to_reload
super(PatchWithReload, self).__init__(*args, **kwargs)
@arcaduf
arcaduf / Python: read and dump dictionary to YAML preserving order
Created January 15, 2018 10:08
Python: read and dump dictionary to YAML preserving order
```python
import collections , yaml
_mapping_tag = yaml.resolver.BaseResolver.DEFAULT_MAPPING_TAG
def dict_representer(dumper, data):
return dumper.represent_mapping(_mapping_tag, data.iteritems())
def dict_constructor(loader, node):
return collections.OrderedDict(loader.construct_pairs(node))
@LuisErnestoZamb
LuisErnestoZamb / 2017-11-29_15-08-33.jpg
Last active October 30, 2023 13:30
How setting up mysql as localhost and using this outside docker on Mac OS (accessing localhost mysql from docker) - The missing guide
2017-11-29_15-08-33.jpg
@kubaszumiato
kubaszumiato / safe.pipe.ts
Created March 23, 2017 20:04
Angular safe pipe implementation to bypass DomSanitizer stripping out content
import {Pipe} from '@angular/core';
import {DomSanitizer, SafeHtml, SafeStyle, SafeScript, SafeUrl, SafeResourceUrl} from '@angular/platform-browser';
//https://forum.ionicframework.com/t/inserting-html-via-angular-2-use-of-domsanitizationservice-bypasssecuritytrusthtml/62562/2
@Pipe({
name: 'safe'
})
export class SafePipe {
constructor(protected _sanitizer: DomSanitizer) {
@michaelneu
michaelneu / Dockerfile
Last active October 17, 2022 05:37
docker-compose configuration for PHP with NGINX and MySQL, including sendmail, MailDev and phpmyadmin
# see https://github.com/cmaessen/docker-php-sendmail for more information
FROM php:5-fpm
RUN apt-get update && apt-get install -q -y ssmtp mailutils && rm -rf /var/lib/apt/lists/*
RUN docker-php-ext-install mysql mysqli sysvsem
RUN pecl install xdebug-2.5.5 \
&& echo "zend_extension=$(find /usr/local/lib/php/extensions/ -name xdebug.so)" > /usr/local/etc/php/conf.d/xdebug.ini \