Skip to content

Instantly share code, notes, and snippets.

View rajitha-bandara's full-sized avatar

Rajitha Bandara rajitha-bandara

View GitHub Profile
@rajitha-bandara
rajitha-bandara / gist:d2a8939bf07fe778cdb5defbc94d42e1
Created May 13, 2017 02:36
Android find original camera image by file Uri
try {
Bitmap bmp = MediaStore.Images.Media.getBitmap(
getContentResolver(), photoFileUri);
photoViewIV.setImageBitmap(bmp);
} catch (IOException e) {
e.printStackTrace();
}
INSERT INTO spatial_ref_sys values (32800, 'EPSG', 32800, 'PROJCS["Transverse_Mercator",GEOGCS["GCS_unnamed ellipse",DATUM["D_unknown",SPHEROID["Unknown",6377276.345,300.8017000000115]],PRIMEM["Greenwich",0],UNIT["Degree",0.017453292519943295]],PROJECTION["Transverse_Mercator"],PARAMETER["latitude_of_origin",7.00048],PARAMETER["central_meridian",80.77171],PARAMETER["scale_factor",0.9999238418],PARAMETER["false_easting",200000],PARAMETER["false_northing",200000],UNIT["Meter",1]]',
'"+proj=tmerc +lat_0=7.00048 +lon_0=80.77171 +k=0.9999238418 +x_0=200000 +y_0=200000 +a=6377276.345 +b=6356075.41314024 +towgs84=-97,787,86,0,0,0,0 +units=m +no_defs"'
)
use Symfony\Component\HttpFoundation\StreamedResponse;
$response = new StreamedResponse(function() use ($request, $data) {
while (true) {
echo 'data: ' . json_encode(['data' => $data]) . "\n\n";
ob_flush();
flush();
usleep(10000000);
}
});
https://htmlpdfapi.com/blog/free_html5_invoice_templates
@rajitha-bandara
rajitha-bandara / woocommerce_products_delete.php
Created September 29, 2017 16:01
WordPress Bulk Delete - WooCommerce Products
require_once( 'wp-load.php' );
global $wpdb;
$sql_1 = "DELETE FROM ".$wpdb->prefix."term_relationships WHERE object_id IN (SELECT ID FROM ".$wpdb->prefix."posts WHERE post_type = 'product');";
$sql_2 = "DELETE FROM ".$wpdb->prefix."postmeta WHERE post_id IN (SELECT ID FROM ".$wpdb->prefix."posts WHERE post_type = 'product');";
$sql_3 = "DELETE FROM ".$wpdb->prefix."posts WHERE post_type = 'product';";
$sql_4 = "DELETE relations.*, taxes.*, terms.*
FROM ".$wpdb->prefix."term_relationships AS relations
@rajitha-bandara
rajitha-bandara / gist:b513c7d65b5b02fd96512e44febc5852
Last active October 5, 2017 06:48
Set up Cent OS 7 Web Server
Manage Security
1.Allow HTTP Service theough firewall
Open Predefined Service
https://www.rootusers.com/how-to-open-a-port-in-centos-7-with-firewalld/
2. Change SSH Port
https://www.globo.tech/learning-center/change-ssh-port-centos-7/
3. Disable Root Login
https://www.digitalocean.com/community/tutorials/initial-server-setup-with-centos-7
LOAD DATA LOCAL INFILE "C:/Users/xxx/e7849261fe2785926565f6c9c4dea6e957c3c837.csv"
INTO TABLE contacts
FIELDS TERMINATED BY ','
ENCLOSED BY '"'
LINES TERMINATED BY '\n'
IGNORE 1 ROWS
@rajitha-bandara
rajitha-bandara / carbon.php
Last active October 13, 2017 11:23
Carbon Date Snippets
Format date time using Carbon
\Carbon\Carbon::createFromFormat($from, $value)->format($to);
\Carbon\Carbon::createFromFormat('Y-m-d H:i:s', '2017-12-10 01:00:00')->format('d/m/Y H:i')
Validate & format Carbon date
if (! function_exists('carbon_date_or_null_if_zero')) {
function convert_datetime_to_carbon($value, $from = 'Y-m-d H:i:s', $to = 'd/m/Y H:i')
{
if(empty($value)){
return null;
@rajitha-bandara
rajitha-bandara / gist:0254c6ee21b10bfb0e7c32de75b61d3a
Last active December 18, 2017 19:41
WordPress Multi Purpose Themes
https://8degreethemes.com/wordpress-themes/
https://www.navthemes.com/free-wordpress-theme/constra/
http://demo.navthemes.com/?demo=plain-blog-theme
http://demo.navthemes.com/?demo=truewest-free-multipurpose-wordpress-theme&c=rsOSrXFBK
http://demo.mysterythemes.com/owner/
Generate ssh in web server
go to /var/www
sudo -u www-data ssh-keygen
sudo cat .ssh/id_rsa.pub
set this in gitlab deployment keys
sudo -u www-data mkdir xxxxxx