Skip to content

Instantly share code, notes, and snippets.

View StokicDusan's full-sized avatar

Dušan Stokić StokicDusan

View GitHub Profile
@StokicDusan
StokicDusan / searchText.md
Last active August 28, 2022 18:04
A way to find all files which contain string

A way to find all files which contain specific text

find -type f -exec grep -IH 'word' {} \;

If the patters are in a file, use:

xargs -a patterns.txt -I% find Folder/ -name %
@StokicDusan
StokicDusan / badBlocks.sh
Created October 16, 2021 11:38
How to find and avoid bad blocks on hard disk.
# This is a script for finding bad blocks on hard drive.
# Repace "/dev/sdb" with disk you wish to check.
sudo fdisk -l
sudo badblocks -v /dev/sdb > /tmp/bad-blocks.txt
sudo e2fsck -l /tmp/bad-blocks.txt /dev/sdb

In terminal use the commands
xdg-open . <!--- open here --->
browse . <!--- open here --->
xdg-open <file_name> <!--- open file_name--->
browse . <file_name> <!--- open file_name--->

@StokicDusan
StokicDusan / datePicker.xml
Created August 31, 2021 18:01
Create a date picker widget for android app
<DatePicker
android:id="@+id/datePicker"
style="@android:style/Widget.DatePicker"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:endYear="2100"
android:spinnersShown="true"
android:startYear="1900">
</DatePicker>
@StokicDusan
StokicDusan / sqlInjectionPHP.md
Last active October 16, 2021 11:39
Preventing an SQL injection attack in PHP using prepared statements

A way you can protect your code against SQL injections is using prepared statements.
Prepared statements are precompiled SQL commands.
Using MySQLi Object-Oriented:

<?php
 $conn = new mysqli($servername, $username, $password, $dbname);

 $query = $conn->prepare('SELECT * FROM student WHERE name = ?');
 $query-&gt;bind_param('s', $name); // 's' specifies the variable type string