Skip to content

Instantly share code, notes, and snippets.

@0bach0
0bach0 / remind-adblock-user.js
Created February 12, 2021 17:25
For display an alert for remind user to help me run this page
// Need jQuery
// dataType and crossDomain for ignore CORS
// In case of loading adsbygoogle.js success, it still throw error related to the callback. That's why I only catch the 404 error
$.ajax({
type: "HEAD", url: "https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js",
dataType: 'jsonp',
crossDomain: true,
success: function (data, text) {
// skip
@0bach0
0bach0 / convert-file-name.sh
Last active April 4, 2020 14:40
Remove unused character in filename
# Input format `CD-47 9課 聴解2 漫画アニメが学べる大学.mp3`
# Output `CD-47.mp3`
find . | while read f; do mv "$f" "${f:0:10}.mp3"; done
@0bach0
0bach0 / image-crawler-with-bash.sh
Created March 14, 2020 01:27
I found a free manga, which is a bunch of image. I decided to download and store on my local computer
# I will hide the original source by [somewher], the file name will start by [abcd]
# 1st version: just assume there're around unlimit file. Will halt the command by using `Ctrl + C` when programs throw 404
for i in $(seq 1 10000); do curl -o abcd-${i}.jpg https://somewhere/${i}; done
# 2nd version: skip the progress bar and output only the http status code.
for i in $(seq 1 10000); do curl -w "%{http_code}" -s -o abcd-${i}.jpg https://somewhere/${i} | xargs; done
# 3rd version: there're around 130 images. So will download 150 images. After that can delete the empty image by UI (open the folder and check the thumbnail)
for i in $(seq 1 150); do curl -s -o abcd-${i}.jpg https://somewhere/${i} | xargs; done
package jp.vietpro.vta;
public class SubSequence {
public static boolean isSubsequence(String s, String t) {
if(s.length()==0)
return true;
int sI=0;
for (int tI=0; tI < t.length(); tI++ ){
if (t.charAt(tI) == s.charAt(sI)){
package jp.vietpro.vta;
class Solution {
public static int romanToInt(String s) {
int value = 0;
char prevValue = '0';
for (int i = 0; i < s.length(); i++) {
if(i > 0)
prevValue = s.charAt(i-1);
2018-05-22 23:41:01.412 ERROR 42181 --- [nio-8080-exec-3] o.a.c.c.C.[.[.[/].[dispatcherServlet] : Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is java.lang.NullPointerException] with root cause
java.lang.NullPointerException: null
at com.csam.general.service.DormitoryRegistrationServiceImpl.initRegistration01(DormitoryRegistrationServiceImpl.java:61) ~[classes/:na]
at com.csam.general.controller.DormitoryRegistrationController.registration01Get(DormitoryRegistrationController.java:37) ~[classes/:na]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_151]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_151]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_151]
at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_151]
at org.springframework.web.method.support.InvocableHandlerMethod.doIn