Skip to content

Instantly share code, notes, and snippets.

@Alexzanderk
Alexzanderk / repositoryService.ts
Created March 1, 2021 13:56
sequelize generic repository service
type Constructor<T> = new (...args: any[]) => T;
type ModelType<T extends Model<T>> = Constructor<T> & typeof Model;
export interface IRepository<T extends Model> {
get(id: string): Promise<T| null>;
find(where: FindOptions<T>): Promise<T>;
create(model: T): Promise<T>;
update(key: any, model: T): Promise<T>;
}
@davipatti
davipatti / thinkpad-setup.md
Last active December 17, 2019 01:14
ThinkPad Ubuntu setup

ThinkPad setup

Notes from installing Ubuntu 18.04 on a Lenovo ThinkPad X1 Extreme, with nvidia graphics.

  • Turn off secure boot in the BIOS.

Installer freezing / non-responsive

@bcnzer
bcnzer / postman-pre-request.js
Last active April 16, 2025 06:21
Postman pre-request script to automatically get a bearer token from Auth0 and save it for reuse
const echoPostRequest = {
url: 'https://<my url>.auth0.com/oauth/token',
method: 'POST',
header: 'Content-Type:application/json',
body: {
mode: 'application/json',
raw: JSON.stringify(
{
client_id:'<your client ID>',
client_secret:'<your client secret>',
@firatkucuk
firatkucuk / delete-slack-messages.js
Last active March 28, 2025 08:17
Deletes slack public/private channel messages, private chat messages and channel thread replies.
#!/usr/bin/env node
// Channel ID is on the the browser URL.: https://mycompany.slack.com/messages/MYCHANNELID/
// Pass it as a parameter: node ./delete-slack-messages.js CHANNEL_ID
// CONFIGURATION #######################################################################################################
const token = 'SLACK TOKEN';
// Legacy tokens are no more supported.
// Please create an app or use an existing Slack App
@niranjv
niranjv / install_python_36_amazon_linux.sh
Last active January 30, 2023 21:49
Install Python 3.6 in Amazon Linux
# A virtualenv running Python3.6 on Amazon Linux/EC2 (approximately) simulates the Python 3.6 Docker container used by Lambda
# and can be used for developing/testing Python 3.6 Lambda functions
# This script installs Python 3.6 on an EC2 instance running Amazon Linux and creates a virtualenv running this version of Python
# This is required because Amazon Linux does not come with Python 3.6 pre-installed
# and several packages available in Amazon Linux are not available in the Lambda Python 3.6 runtime
# The script has been tested successfully on a t2.micro EC2 instance (Root device type: ebs; Virtualization type: hvm)
# running Amazon Linux AMI 2017.03.0 (HVM), SSD Volume Type - ami-c58c1dd3
# and was developed with the help of AWS Support
@nirmalpathak
nirmalpathak / nginx.conf
Last active November 6, 2021 10:16
Sample nginx.conf which for SonarQube 5.6.3
# For more information on configuration, see:
# * Official English Documentation: http://nginx.org/en/docs/
# * Official Russian Documentation: http://nginx.org/ru/docs/
user nginx;
worker_processes auto;
error_log /var/log/nginx/error.log;
pid /run/nginx.pid;
# Load dynamic modules. See /usr/share/nginx/README.dynamic.
@mattiaslundberg
mattiaslundberg / Ansible Let's Encrypt Nginx setup
Last active January 30, 2025 19:01
Let's Encrypt Nginx setup with Ansible
Ansible playbook to setup HTTPS using Let's encrypt on nginx.
The Ansible playbook installs everything needed to serve static files from a nginx server over HTTPS.
The server pass A rating on [SSL Labs](https://www.ssllabs.com/).
To use:
1. Install [Ansible](https://www.ansible.com/)
2. Setup an Ubuntu 16.04 server accessible over ssh
3. Create `/etc/ansible/hosts` according to template below and change example.com to your domain
4. Copy the rest of the files to an empty directory (`playbook.yml` in the root of that folder and the rest in the `templates` subfolder)
/**
* (1)Get tweets by search keyword and (2)Stemming(Korean), (3)save to mysql finally
*/
var Promise = require('bluebird');
var TwitterKoreanText = require('twtkrjs');
var twitterKoreanText = new TwitterKoreanText({
stemmer: true, // (optional default: true)
normalizer: true, // (optional default: true)
@pocmo
pocmo / gist:bc95238e890a185003c4
Last active November 24, 2019 14:24
Android M-Preview 1 - Permissions + Groups + Protection Level
(android.permission-group.CONTACTS) android.permission.READ_CONTACTS dangerous
(android.permission-group.CONTACTS) android.permission.WRITE_CONTACTS dangerous
(android.permission-group.CONTACTS) android.permission.READ_PROFILE dangerous
(android.permission-group.CONTACTS) android.permission.WRITE_PROFILE dangerous
(android.permission-group.CALENDAR) android.permission.READ_CALENDAR dangerous
(android.permission-group.CALENDAR) android.permission.WRITE_CALENDAR dangerous
(android.permission-group.SMS) android.permission.SEND_SMS dangerous
(android.permission-group.SMS) android.permission.RECEIVE_SMS dangerous
(android.permission-group.SMS) android.permission.READ_SMS dangerous
(android.permission-group.SMS) android.permission.RECEIVE_WAP_PUSH dangerous
@ganadist
ganadist / gist:2af47d422ca6f9d30e8d
Last active March 3, 2021 20:24
SafetyNet example
private static final DEBUG = false;
private static final SecureRandom SR;
static {
SR = new SecureRandom();
SR.setSeed(System.currentTimeMillis());
}
private byte[] getRequestNonce() {
byte[] output = new byte[16];