Skip to content

Instantly share code, notes, and snippets.

@renhuailin
renhuailin / list-latest-file-in-folder.py
Created November 27, 2019 06:37
List latest file in folder
folder = "/Users/harley/Documents"
files_path = os.path.join(folder, '*')
onlyfiles = [join(folder, f)
for f in listdir(folder) if not f.startswith(".") and isfile(join(folder, f))]
files = sorted(
onlyfiles, key=os.path.getctime, reverse=True)
print(files[0])
@renhuailin
renhuailin / GenerateJWK_JWT_VERIFY_JWT.java
Created November 19, 2018 08:08
生成JWK,JWT,并验证JWT
package org.compile.demo;
import java.io.*;
import java.util.Arrays;
import java.util.List;
import java.security.PrivateKey;
import org.slf4j.*;
import org.jose4j.jwa.*;
import org.jose4j.jwk.*;
import org.jose4j.jwt.*;
@renhuailin
renhuailin / python3_base64_encode.py
Last active July 11, 2018 02:48
Python3 Base64 encode
import base64
s = 'some text'
#转成bytes string
bytesString = s.encode(encoding="utf-8")
print(bytesString)
#base64 编码
encodestr = base64.b64encode(bytesString)
@renhuailin
renhuailin / app.component.ts
Last active December 28, 2017 07:14
Meteor get query parameters passed by URL
import { OnInit, Component } from '@angular/core';
import { Router, ActivatedRoute, Params } from '@angular/router';
@Component({
selector: 'app',
templateUrl: 'app.html'
})
export class AppComponent implements OnInit {
constructor(
@renhuailin
renhuailin / gist:e33b0f55e834fab31ff4
Created September 28, 2014 14:15
jquery table remove tr has td
$("tr:has(td)").remove();
@renhuailin
renhuailin / Read_Entire_File_As_String.rb
Created August 29, 2014 09:32
Ruby ,read entire file as string
s = File.open(filename, 'rb') { |f| f.read }
@renhuailin
renhuailin / RubyStringReader.rb
Last active August 29, 2015 14:05
Ruby String reader
require 'stringio'
picArrayStr = <<HMPS
arrayOfInteger2[131] = 20056;
arrayOfInteger2[132] = 20057;
arrayOfInteger2[133] = 20058;
arrayOfInteger2[134] = 20059;
arrayOfInteger2[135] = 20060;
arrayOfInteger2[136] = 20061;
arrayOfInteger2[137] = 20062;