Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@Ikki-Dai
Ikki-Dai / SpringDataJdbcConfiguration.java
Last active April 23, 2024 09:52
CustomerEnumConverter
@Configuration
@Slf4j
public class SpringDataJdbcConfiguration extends AbstractJdbcConfiguration {
@Override
public JdbcCustomConversions jdbcCustomConversions() {
return new JdbcCustomConversions(Arrays.asList(Enum2Integer.INSTANCE,
new Integer2Enum<>(Account.Gender.class)));
}
@barrysteyn
barrysteyn / Base64Decode.c
Last active April 23, 2024 09:50
Base64 Encoding/Decoding with the OpenSSL c api
//Decodes Base64
#include <openssl/bio.h>
#include <openssl/evp.h>
#include <string.h>
#include <stdio.h>
int calcDecodeLength(const char* b64input) { //Calculates the length of a decoded base64 string
int len = strlen(b64input);
int padding = 0;
@JoeyBurzynski
JoeyBurzynski / crawler-user-agent-strings-with-descriptions.txt
Created October 22, 2018 16:25
Bot & Crawler User Agents Strings with Descriptions
Googlebot/2.1 (+http://www.google.com/bot.html) # Pattern: Googlebot\/ / URL: http://www.google.com/bot.html
Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html) # Pattern: Googlebot\/ / URL: http://www.google.com/bot.html
Mozilla/5.0 (iPhone; CPU iPhone OS 6_0 like Mac OS X) AppleWebKit/536.26 (KHTML, like Gecko) Version/6.0 Mobile/10A5376e Safari/8536.25 (compatible; Googlebot/2.1; +http://www.google.com/bot.html) # Pattern: Googlebot\/ / URL: http://www.google.com/bot.html
Mozilla/5.0 (iPhone; CPU iPhone OS 8_3 like Mac OS X) AppleWebKit/537.36 (KHTML, like Gecko) Version/8.0 Mobile/12F70 Safari/600.1.4 (compatible; Googlebot/2.1; +http://www.google.com/bot.html) # Pattern: Googlebot\/ / URL: http://www.google.com/bot.html
Mozilla/5.0 (iPhone; CPU iPhone OS 8_3 like Mac OS X) AppleWebKit/600.1.4 (KHTML, like Gecko) Version/8.0 Mobile/12F70 Safari/600.1.4 (compatible; Googlebot/2.1; +http://www.google.com/bot.html) # Pattern: Googlebot\/ / URL: http://www.google.com/bot.html
Mozilla
@joerodgers
joerodgers / Get-KeyVaultSecret.ps1
Last active April 23, 2024 09:44
Example using REST and PowerShell to retrieve a secret from Azure Key Vault via AAD Service Principal credential
function Get-AccessToken
{
[CmdletBinding()]
param
(
[Parameter(Mandatory=$true,ParameterSetName='Resource')]
[Parameter(Mandatory=$true,ParameterSetName='Scope')]
[string]$ClientId,
[Parameter(Mandatory=$true,ParameterSetName='Resource')]
@brun0xff
brun0xff / code-tag.txt
Created June 22, 2018 14:53
TODO: FIXME, HACK, and REVIEW
# Use TODO to note missing features or functionality that should be added at a later date.
# Use FIXME to note broken code that needs to be fixed.
# Use OPTIMIZE to note slow or inefficient code that may cause performance problems.
# Use HACK to note code smells where questionable coding practices were used and should be refactored away.
# Use REVIEW to note anything that should be looked at to confirm it is working as intended.
@yanaiela
yanaiela / word2vec-download300model.sh
Last active April 23, 2024 09:42
simple bash script for downloading the Google word2vec model (https://code.google.com/archive/p/word2vec/) from Google-Drive
#!/bin/bash
# usage:
# first make the file executable
# ./word2vec-download300model.sh output-file
OUTPUT=$( wget --save-cookies cookies.txt --keep-session-cookies --no-check-certificate 'https://docs.google.com/uc?export=download&id=0B7XkCwpI5KDYNlNUTTlSS21pQmM' -O- | sed -rn 's/.*confirm=([0-9A-Za-z_]+).*/Code: \1\n/p' )
CODE=${OUTPUT##*Code: }
echo $CODE
@marina-mosti
marina-mosti / useEmptySlotCheck.js
Last active April 23, 2024 09:40
Vue 3 check for slot with no content
import { ref, computed, onBeforeUpdate, Comment, Fragment, Text, useSlots } from 'vue'
// Adapted from https://github.com/vuejs/vue-next/blob/ca17162e377e0a0bf3fae9d92d0fdcb32084a9fe/packages/runtime-core/src/helpers/renderSlot.ts#L77
// Demo: https://play.vuejs.org/#eNqVVm1P3EYQ/iuDU+UOdNiEa0NBHE2gRE1bJVWg/RJH1Z49PhvstbW7PkDX+++d2bV9vmCIggTa3Xl7ZuaZMSvvbVX5yxq9E+9URyqrDGg0dXUWyqyoSmXgoiwqSFRZwMgP+MLqo068AoXJBEp5jkmp8O8qFgYnUGu8ykujYd3YOqNQRqXUBgq9gBlbjke/ZTuj3Y3ElItFbm1JYbwLszMKEUpgE38p8hrpfXP+BWSd53AC1k8o16E8DVwilAJdDBZVTpDoBnDK+O0JYLWyKNZk4R46VXghRYFnaXYabFvb9K1busxrY0oJb6I8i25nobcBHnpnF/wIBZ4GTo2Mes68iWc0pZtkC/9Gl5KKv2KfoRdRgCxH9bEyGZUj9E7ASlgm8ry8+92+GVXjpH2PUoxuB95v9D2/hd5fCjWqJYZeJzNCLZCAsvjy6gPe07kTFmVc56T9jPAT6jKvGaNTO69lTLB7ehbte8uRTC6u9eW9QanbpBgoa66tfugRO7i2T6W+gTv1p9aOOk1VbOnI7N1ulWYCcRu5M6jJFoKehM9b3aXrMP2/j9+N0RX7uCwq88BKF9ygboQGZL3BYHSaGN76H9NoOMkKCK0z0hOIMckkxi2G2VDIsXVmZ2sb/riZK64HOy9z9PNyMXbl3oRxM7YdzL2xJjle0283btSPARBEcOrO88WkNhYozQTeKbFwp2ti3aPdEeztUeA9+BUNqoIgabhL0aSoQNjKQaYdfCD38A/th+k
@joshbuchea
joshbuchea / semantic-commit-messages.md
Last active April 23, 2024 09:38
Semantic Commit Messages

Semantic Commit Messages

See how a minor change to your commit message style can make you a better programmer.

Format: <type>(<scope>): <subject>

<scope> is optional

Example

@lohanidamodar
lohanidamodar / firestore_service.dart
Created February 19, 2020 02:30
Flutter firestore generic helper class
import 'package:cloud_firestore/cloud_firestore.dart';
class DatabaseService<T> {
final String collection;
final Firestore _db = Firestore.instance;
final T Function(String, Map<String,dynamic>) fromDS;
final Map<String,dynamic> Function(T) toMap;
DatabaseService(this.collection, {this.fromDS,this.toMap});
Future<T> getSingle(String id) async {
var snap = await _db.collection(collection).document(id).get();
if(!snap.exists) return null;
@integeruser
integeruser / extract-symbol-info-in-macho.py
Last active April 23, 2024 09:36
Extract symbols information (e.g. addresses) from Mach-O files
#!/usr/bin/env python3
import ctypes
LC_SYMTAB = 0x2
class mach_header_64(ctypes.Structure):
_fields_ = (
("magic", ctypes.c_uint32),
("cputype", ctypes.c_uint32),