Skip to content

Instantly share code, notes, and snippets.

View lamjar's full-sized avatar
🥇
FullStack Developer | iTDev Tunisia Inc

Lamjed JARRAY lamjar

🥇
FullStack Developer | iTDev Tunisia Inc
View GitHub Profile
@lamjar
lamjar / AESenc.java
Created July 30, 2018 11:25 — forked from SimoneStefani/AESenc.java
Example of AES encryption and decryption in Java
/**
* Code written by P. Gajland
* https://github.com/GaPhil
*/
import java.security.Key;
import javax.crypto.Cipher;
import sun.misc.BASE64Encoder;
import sun.misc.BASE64Decoder;
import javax.crypto.spec.SecretKeySpec;
@lamjar
lamjar / postgresql_changes_tracking.sql
Created June 1, 2018 14:56 — forked from cristianp6/postgresql_changes_tracking.sql
Log row changes in PostgreSQL - Any advice/improvement is welcome ;-)
/**
* Creates a "logging" schema with an "history" table where are stored records in JSON format
*
* Requires PostgreSQL >= 9.3 since data is stored in JSON format
*
* Credits: http://www.cybertec.at/2013/12/tracking-changes-in-postgresql/
*/
/* Create a schema dedicated to logs */
CREATE SCHEMA logging;
@lamjar
lamjar / AES256Cryptor.java
Created April 6, 2018 15:00 — forked from kientux/AES256Cryptor.java
Encrypt and decrypt AES-256 (in CryptoJS way)
/**
* Created by kientux on 3/20/15
*/
import android.util.Base64;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.security.SecureRandom;
import java.util.Arrays;
@lamjar
lamjar / file-size.pipe.ts
Created January 31, 2018 14:54 — forked from JonCatmull/file-size.pipe.ts
Angular2 + TypeScript file size Pipe/Filter. Convert bytes into largest possible unit. e.g. 1024 => 1 KB
import { Pipe, PipeTransform } from '@angular/core';
/*
* Convert bytes into largest possible unit.
* Takes an precision argument that defaults to 2.
* Usage:
* bytes | fileSize:precision
* Example:
* {{ 1024 | fileSize}}
* formats to: 1 KB
@lamjar
lamjar / Spring.Boot.Server.Random.Port.java
Created January 15, 2018 15:26 — forked from BorzdeG/Spring.Boot.Server.Random.Port.java
Spring Boot :: set random server port
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.autoconfigure.web.ServerPropertiesAutoConfiguration;
import org.springframework.boot.context.embedded.ConfigurableEmbeddedServletContainer;
import org.springframework.context.annotation.Configuration;
import java.io.IOException;
import java.net.ServerSocket;
@Configuration
@lamjar
lamjar / UnlockUserLDAP.java
Last active January 5, 2018 09:16 — forked from vegaasen/UnlockUser.java
Unlock user in AD using java and UnBoundID :-)
/**
* Simplifies the process of unlocking users.
* <p>
* The AD attribute "userAccountControl" may be any of the following
* - 512 Enabled Account (normally this..)
* - 514 Disabled Account
* - 544 Enabled, Password Not Required
* - 546 Disabled, Password Not Required
* - 66048 Enabled, Password Doesn't Expire
* - 66050 Disabled, Password Doesn't Expire
@lamjar
lamjar / jquery-alert-hack.js
Created October 13, 2017 15:44 — forked from lu1s/jquery-alert-hack.js
jQuery alert() beautify and more user friendly
/*
* This function replaces the javascript native alert() function.
* I know that by convention it's not a good practice, but if you want to
* follow strict stuff, just declare the function with another name and
* call it as that.
*
* jQuery.js is required (http://jquery.com)
*
* The function can be called like this:
* For static (not auto-hide) alert bar:
@lamjar
lamjar / PlacesRESTController.java
Created July 3, 2017 13:04 — forked from wvuong/PlacesRESTController.java
Simple generic REST-ful Spring MVC controller, interops with Spring Data repositories
package com.willvuong.foodie.controller;
import com.willvuong.foodie.dao.PlaceRepository;
import com.willvuong.foodie.domain.Place;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.repository.CrudRepository;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;