View markdown-to-pdf-2.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var fs = require("fs") | |
fs.createReadStream("apache-camel-build.md") | |
.pipe(markdownpdf()) | |
.pipe(fs.createWriteStream("apache-camel-build.pdf")) |
View markdown-to-pdf-1.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var markdownpdf = require("markdown-pdf") | |
markdownpdf().from("apache-camel-build.md").to("apache-camel-build.pdf", function () { | |
console.log("Done") | |
}) |
View drop_tables_in_ms_sql_server.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- https://www.mssqltips.com/sqlservertip/6798/drop-all-tables-sql-server/ | |
USE [BikeStores] | |
GO | |
-- drop constraints | |
DECLARE @DropConstraints NVARCHAR(max) = '' | |
SELECT @DropConstraints += 'ALTER TABLE ' + QUOTENAME(OBJECT_SCHEMA_NAME(parent_object_id)) + '.' | |
+ QUOTENAME(OBJECT_NAME(parent_object_id)) + ' ' + 'DROP CONSTRAINT' + QUOTENAME(name) | |
FROM sys.foreign_keys | |
EXECUTE sp_executesql @DropConstraints; |
View StdoutCatcher.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static String catchStdout(Runnable runnable) { | |
ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); | |
System.setOut(new PrintStream(outputStream)); | |
runnable.run(); | |
return outputStream.toString(); | |
} | |
@Test | |
void testCatchStdout() { | |
String s = "Hello, World"; |
View myhandle.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// https://stackoverflow.com/questions/52797992/which-rxjs-operator-to-choose-to-handle-http-errors-tap-or-catcherror/61836193#61836193 | |
// "tap" is to cause side effects and it doesn't modify the chain at all, "catchError" is to catch errors in a stream and try to handle them. | |
http.get('https://test.com/').pipe( | |
tap( | |
() => { | |
// 200, awesome!, no errors will trigger it. | |
}, | |
(error: HttpErrorResponse) => { | |
// error is here, but we can only call side things. | |
}, |
View PersonSpecification.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Take sub-string before first space ' ' if there is any or else take the whole string | |
private static Expression<String> nameSplit( | |
Root<Person> root, | |
CriteriaBuilder builder, | |
SingularAttribute<Person, String> str | |
) { | |
Expression<Integer> indexStart = builder.literal(1); | |
Expression<Integer> indexOfFirstSpace = builder.locate(root.get(str), " "); | |
Expression<Integer> stringLength = builder.length(root.get(str)); | |
// if indexOfFirstSpace = 0, then no space ' ' is found |
View script.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# list tags | |
git tag | |
# search tag | |
git tag -l "1.0.*" | |
# add lightweight tag | |
git tag "1.0.0" | |
# delete local tag '1.0.0' | |
git tag -d 1.0.0 | |
# delete remote tag '1.0.0' | |
git push --delete origin 1.0.0 |
View script.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
echo "Stream.of(0b01001000,0b01100001,0b01110000,0b01110000,0b01111001,0b00100000,0b01000010,0b01101001,0b01110010,0b01110100,0b01101000,0b01100100,0b01100001,0b01111001).map(Character::toChars).forEach(System.out::print)" | jshell - |
View script.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Standard error is redirected to standard output, so both are redirected to debug.log | |
perl test.pl > debug.log 2>&1 | |
# Standard output goes to out.log, and standard error to err.log | |
perl test.pl 1>out.log 2>err.log |
View LdapExtension.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package ch.keller.test.extension; | |
import com.unboundid.ldap.listener.InMemoryDirectoryServer; | |
import com.unboundid.ldap.listener.InMemoryDirectoryServerConfig; | |
import com.unboundid.ldap.listener.InMemoryListenerConfig; | |
import com.unboundid.ldif.LDIFReader; | |
import org.junit.jupiter.api.extension.AfterAllCallback; | |
import org.junit.jupiter.api.extension.BeforeAllCallback; | |
import org.junit.jupiter.api.extension.ExtensionContext; | |
import org.slf4j.Logger; |
NewerOlder