Skip to content

Instantly share code, notes, and snippets.

View cnmoro's full-sized avatar
🎯
Focusing

Carlo Moro cnmoro

🎯
Focusing
View GitHub Profile
@cnmoro
cnmoro / MongoDB Drop Field
Created May 28, 2019 18:52
MongoDB Drop Field
db.getCollection('COLL_NAME').update({},{$unset: {FIELD_NAME:1}},{multi: true});
@cnmoro
cnmoro / Gzip.java
Created May 30, 2019 02:15
Java gzip compress/decompress string
import java.io.BufferedReader;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.zip.GZIPInputStream;
import java.util.zip.GZIPOutputStream;
public class Gzip {
@cnmoro
cnmoro / Non-cordova module "glob" is not supported
Created June 11, 2019 18:12
Fix "Non-cordova module "glob" is not supported"
Using "requireCordovaModule" to load non-cordova module "glob" is not supported.
Fix: Downgrade cordova to 8.1.2:
npm install -g [email protected]
@cnmoro
cnmoro / Java GZip String Compression
Created June 13, 2019 16:24
Java GZip String Compression
/**
*
* @author https://stackoverflow.com/users/1964272/dropout
*/
public static String compress(String str) throws IOException {
if (str == null || str.length() == 0) {
return str;
}
ByteArrayOutputStream out = new ByteArrayOutputStream();
GZIPOutputStream gzip = new GZIPOutputStream(out);
@cnmoro
cnmoro / Ionic - Bugfix "Not allowed to load local resource"
Created June 18, 2019 15:33
Ionic - Bugfix "Not allowed to load local resource"
let win: any = window;
path = win.Ionic.WebView.convertFileSrc(path);
@cnmoro
cnmoro / Linux check which window manager is on (x11, wayland..)
Last active July 12, 2019 02:09
Linux check which window manager is on (x11, wayland..)
~$ loginctl
-> get session
~$ loginctl show-session SESSION -p Type
-- OR
~$ echo $XDG_SESSION_TYPE
@cnmoro
cnmoro / Generate JAR with Maven
Created August 1, 2019 14:36
Generate JAR with Maven
<build>
<plugins>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<archive>
<manifest>
<mainClass>fully.qualified.MainClass</mainClass>
</manifest>
</archive>
@cnmoro
cnmoro / Maven .jar Proguard
Created August 5, 2019 17:22
Maven .jar Proguard
<!-- Configures Proguard obfuscation tool to generate an
obfuscated version of the JAR file that replaces the
default unobfuscated JAR.
-- author: Emily Mabrey @ https://stackoverflow.com/questions/34706466/how-do-i-use-proguard-obfuscation-while-building-a-maven-plugin-package
-->
<plugin>
<groupId>com.github.wvengen</groupId>
<artifactId>proguard-maven-plugin</artifactId>
<version>2.0.13</version>
@cnmoro
cnmoro / Java split csv correctly
Created August 5, 2019 18:01
Java split csv correctly
String text = "age: 28,favorite number: 26,\"salary: $1,234,108\"";
String[] strArray = text.split(",(?=([^\"]*\"[^\"]*\")*[^\"]*$)");
for (String s : strArray) {
s = s.replaceAll("\"", "");
}
@cnmoro
cnmoro / MongoDB Integer Regex Query
Created August 7, 2019 13:37
MongoDB Integer Regex Query
Number query example: 400105
db.getCollection('COLLECTION_NAME').find({ $where: "/^400105.*/.test(this.FIELD_TO_MATCH)"})