Skip to content

Instantly share code, notes, and snippets.

@mecid
mecid / Calendar.swift
Last active May 8, 2024 13:30
SwiftUI Calendar view using LazyVGrid
import SwiftUI
extension Calendar {
func generateDates(
inside interval: DateInterval,
matching components: DateComponents
) -> [Date] {
var dates: [Date] = []
dates.append(interval.start)
@proteye
proteye / rsa_pem.dart
Last active March 19, 2024 08:59
How to encode/decode RSA private/public keys to PEM format in Dart with asn1lib and pointycastle
import 'dart:convert';
import 'dart:math';
import 'dart:typed_data';
import "package:pointycastle/export.dart";
import "package:asn1lib/asn1lib.dart";
List<int> decodePEM(String pem) {
var startsWith = [
"-----BEGIN PUBLIC KEY-----",
"-----BEGIN PRIVATE KEY-----",
@benorama
benorama / EventBusService.ts
Created April 22, 2017 10:40
Typescript version of Vertx EventBus Client for Angular
/**
* Based on Vertx EventBus Client (https://github.com/vert-x3/vertx-bus-bower)
* Requires SockJS Client
*/
import {EventEmitter, Injectable} from "@angular/core";
import * as SockJS from 'sockjs-client';
@Injectable()
export class EventBusService {
@hacksoldier
hacksoldier / EncryptionUtil.java
Created March 2, 2016 17:09
Simple Encryption and Decryption java class
package it.reexon.reexon.lib.crypt;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.security.KeyPair;
@alexniver
alexniver / golang, ubuntu go get in china.md
Last active April 26, 2023 11:15
ubuntu下, 使用shadowsock和Privoxy帮助你在命令行中, 无障碍进行go get

#前言 由于大家都懂的, 国内使用go get的时候, 经常会各种失败, 如果有vpn的话, 打开vpn, 问题就解决了, 但vpn其实挺不灵活的.

相对来说shadowsock则灵活得多.

#解决方案 shadowsock + Privoxy

思路就是, 使用shadowsock建立一个本地sock5代理, 但因为go get 需要http代理, 所以需要使用privoxy把sock5代理转为http代理.

@jhngrant
jhngrant / postgresql-debugger-install-ubuntu
Last active September 26, 2022 21:23
Installing the PL/pgSQL Debugger Extension (pldbgapi) for pgAdmin III on PostgreSQL 9.4 and Ubuntu 14.10
# PostgreSQL can be on a remote server but you'll need root privileges in Linux and superuser in PostgreSQL.
# First install build tools
sudo su
aptitude install build-essential
aptitude install postgresql-server-dev-9.4
# Clone and build the PL/pgSQL server-side debugger
@welshstew
welshstew / groovy-zip.groovy
Created March 5, 2015 04:41
groovy script to zip and unzip text/String content
// Simple groovy script to compress / decompress Strings
import java.util.zip.GZIPInputStream
import java.util.zip.GZIPOutputStream
def zip(String s){
def targetStream = new ByteArrayOutputStream()
def zipStream = new GZIPOutputStream(targetStream)
zipStream.write(s.getBytes('UTF-8'))
zipStream.close()
def zippedBytes = targetStream.toByteArray()
@uebo
uebo / Default-568h@2x.png
Last active October 12, 2022 01:41
iOS Sample Launch Screen File
Default-568h@2x.png
@mobilemind
mobilemind / git-tag-delete-local-and-remote.sh
Last active May 13, 2024 23:23
how to delete a git tag locally and remote
# delete local tag '12345'
git tag -d 12345
# delete remote tag '12345' (eg, GitHub version too)
git push origin :refs/tags/12345
# alternative approach
git push --delete origin tagName
git tag -d tagName
@kdabir
kdabir / README.md
Last active November 20, 2017 08:26
Creating and Scheduling a TimerTask in groovy

Creating a TimerTask can not get easier than this thanks to groovy.

  • import java.util.timer.* is not required as java.util is already imported.
  • the run() is implemented as closure

To Run this:

groovy https://gist.github.com/kdabir/3176945/raw/timer_example.groovy