Skip to content

Instantly share code, notes, and snippets.

View Faz95210's full-sized avatar

fawzi bedidi Faz95210

View GitHub Profile
@Faz95210
Faz95210 / Process.md
Created January 25, 2019 14:43
[Get last reboot time and reason on Windows] Process to get the last time and reason of a reboot on windows server #WindowsServer
  1. Press the Windows + R keys to open the Run dialog, type eventvwr.msc, and press Enter.

  2. If prompted by UAC, then click/tap on Yes (Windows 7/8) or Continue (Vista).

  3. In the left pane of Event Viewer, double click/tap on Windows Logs to expand it, click on System to select it, then right click on System, and click/tap on Filter Current Log.

    A. Click/tap on the drop down arrow to the right of Event sources, check the USER32 box, and click/tap in the field.

@Faz95210
Faz95210 / .htaccess
Created June 25, 2018 06:14
[Prevent direct url to pictures] Stop users to use direct url to see pictures. #htaccess #web #permissions
RewriteEngine on
RewriteCond %{HTTP_REFERER} !^http://(www\.)?10.0.1.19 [NC]
RewriteCond %{HTTP_REFERER} !^http://(www\.)?10.0.1.19.*$ [NC]
RewriteRule \.(gif|jpg|png|pdf)$ - [F]
@Faz95210
Faz95210 / how-to.md
Last active June 15, 2018 09:56
[Creating Service with NSSM] How to create a windows service with nssm #Windows #Service #NSSM
  • Install the latest version in : http://nssm.cc/download
  • Unzip it
  • through the console navigate to the repository
  • Launch nssm.exe install service_name

voilà :)

@Faz95210
Faz95210 / SqlHandler.php
Created June 15, 2018 04:05
[Copy an SQLServer table to another in PHP] Copy the content from an SQLserver table to another #PHP #SQLserver
private function copyTableToTable($dbSrc, $dbDest, $tableSrc, $tableDest = null) {
if ($tableDest == null) { // If null then assume tables have same name
$tableDest = $tableSrc;
}
$dbDest->query("TRUNCATE TABLE $tableDest"); //Empty Dest table in case it's not already done.
$columns = $this->db->query("SELECT c.name FROM"
. " sys.columns c"
. " INNER JOIN "
. " sys.types t ON c.user_type_id = t.user_type_id"
. " LEFT OUTER JOIN "
@Faz95210
Faz95210 / query.sqlsrv
Created June 13, 2018 09:47
[Get columns list SQLserver] Get table's column in sql server #SQLServer
SELECT c.name 'Column Name'
FROM sys.columns c
INNER JOIN sys.types t ON c.user_type_id = t.user_type_id
LEFT OUTER JOIN
sys.index_columns ic ON ic.object_id = c.object_id AND ic.column_id = c.column_id
LEFT OUTER JOIN
sys.indexes i ON ic.object_id = i.object_id AND ic.index_id = i.index_id
WHERE
c.object_id = OBJECT_ID('YOUR_TABLE_NAME')
@Faz95210
Faz95210 / LogManager.java
Created June 13, 2018 03:55
[Programmatically set log4J file output] Set in the program the file output of log4j logs #Java #Logs #Log4J
/*
* Set logger's appender. If the logger is local, the change will only be local.
*/
private void setAppender() {
SimpleLayout layout = new SimpleLayout();
FileAppender appender = null;
try {
appender = new FileAppender(layout, "path/to/your/logs.log", true); //true = append; false = replace
} catch (IOException e) {
e.printStackTrace();
@Faz95210
Faz95210 / main.java
Created June 12, 2018 03:29
[Create Cron in Java] Create a cron in java using java utils #Java #Cron #Utils
/**
* Init an action to be run every sunday at 10 AM.
*/
private static void initCron() {
final Calendar calendar = Calendar.getInstance();
calendar.set(
Calendar.DAY_OF_WEEK,
Calendar.SUNDAY
@Faz95210
Faz95210 / snippet.js
Created June 7, 2018 10:30
[JS incompatibilities with Internet Explorer] List of javascript functionalities not compatible with internet explorer #IE #JS
## Template String
$(`#id=${var}`);
## Parameters Assignment
function open(multiCartId = -1)
@Faz95210
Faz95210 / ExcelHandler.Java
Last active May 29, 2018 05:59
[Parse xlsx from java] Parse xlsx excel file from java with apache poi #Java #Excel #Xlsx #Apache #POI
import org.apache.poi.openxml4j.exceptions.NotOfficeXmlFileException;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Workbook;
/*
** Gradle Import :
* compile group: 'org.apache.poi', name: 'poi', version: '3.17'
* compile group: 'org.apache.poi', name: 'poi-ooxml', version: '3.17'
@Faz95210
Faz95210 / build.gradle
Last active May 29, 2018 02:58
[Create .exe with Java, Launch4J and Gradle] How to generate a .exe in java with gradle and launch4J #Java #Gradle #Launch4J #executable #windows
buildscript {
repositories {
mavenCentral()
jcenter()
}
dependencies {
classpath group: 'edu.sc.seis.gradle', name: 'launch4j', version: '2.4.3' // dependency for the launch4J plugin
}
}