Skip to content

Instantly share code, notes, and snippets.

/*
Display Custom Characters on 16×2 LCD
For more details, visit: https://techzeero.com/arduino-tutorials/custom-characters-on-16x2-lcd/
*/
#include<LiquidCrystal.h>
LiquidCrystal lcd(12,11,5,4,3,2);
byte smile[8] = {0b00000,0b01010,0b00000,0b00000,0b10001,0b01110,0b00000,0b00000};
@jlaine
jlaine / pagination-page.ts
Last active November 2, 2020 09:35
Angular pagination - page
export class Page<T> {
count: number; // total number of items
next: string; // URL of the next page
previous: string; // URL of the previous page
results: Array<T>; // items for the current page
}
@mobynote
mobynote / DemoRepository
Created March 7, 2018 03:17
Use jdbcTemplate implement a pagination in spring
package com.domain;
import com.domain.Module;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageImpl;
import org.springframework.data.domain.Pageable;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Repository;
@MgenGlder
MgenGlder / map.js
Last active December 18, 2020 03:14
Convert map to http params
mapToHttpParams(params)
function mapToHttpParams (m : Map) : String {
let s = "";
if (!empty(m)) {
for(let key in m) {
let value = m[key];
if (!empty(value)) {
s = StringUtils.format("{0}{1}{2}={3}",
s,
(s.length != 0) ? "&":"",
@felipeochoa
felipeochoa / comment-form.js
Created April 7, 2017 16:35
@-mentions for Quill
const quillModules = {
toolbar: ["bold", "italic", "underline", "strike"],
// mentions is added in constructor
keyboard: {
bindings: {
tab: {
key: 9,
handler: function(range, context) {
return this.quill.mentionHandler(range.context);
}
@liufuyang
liufuyang / tailc
Last active April 15, 2024 02:31
Color output of linux tail command
#!/bin/bash
# save this file as tailc then
# run as: $ tailc logs/supplier-matching-worker.log Words_to_highlight
file=$1
if [[ -n "$2" ]]; then
color='
// {print "\033[37m" $0 "\033[39m"}
/(WARN|WARNING)/ {print "\033[1;33m" $0 "\033[0m"}
/(ERROR|CRIT)/ {print "\033[1;31m" $0 "\033[0m"}
@benwells
benwells / reduce-example.js
Created May 12, 2016 13:40
Using Array.reduce to sum a property in an array of objects
var accounts = [
{ name: 'James Brown', msgCount: 123 },
{ name: 'Stevie Wonder', msgCount: 22 },
{ name: 'Sly Stone', msgCount: 16 },
{ name: 'Otis Redding', msgCount: 300 } // Otis has the most messages
];
// get sum of msgCount prop across all objects in array
var msgTotal = accounts.reduce(function(prev, cur) {
return prev + cur.msgCount;
@LorisBachert
LorisBachert / TikaExtractor.java
Last active June 15, 2024 15:45
Using Apache TIKA to extract the following formats: DOC, DOCX, PPT, PPTX, XLS, XLSX, PDF, JPG, PNG, TXT Note: Tesseract must be installed in order to get JPG and PNG extraction working.
/**
* Uses Tikas {@link AutoDetectParser} to extract the text of a file.
*
* @param document
* @return The text content of a file
*/
@Override
public String extractTextOfDocument(File file) throws Exception {
InputStream fileStream = new FileInputStream(file);
Parser parser = new AutoDetectParser();
@michaelames
michaelames / gist:f16ee975ddad15cf3527
Created April 28, 2015 15:46
Simplest possible example of Java authentication to LDAP Server (including Active Directory)
import java.util.Hashtable;
import java.io.Console;
import javax.naming.Context;
import javax.naming.directory.DirContext;
import javax.naming.directory.InitialDirContext;
public class TestAuth {
public static void main(String[] args) {
@MariusVolkhart
MariusVolkhart / WhereClause.java
Last active June 29, 2022 23:53
A small utility to help you construct SQL query where clauses
/*
* Copyright 2014-2015 Marius Volkhart
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software