Skip to content

Instantly share code, notes, and snippets.

View thecfguy's full-sized avatar

Pritesh thecfguy

View GitHub Profile
BUCKET_NAME=YOUR_BUCKKET_NAME
KEY_PREFIX="folder/to/restore"
# list all files having deleteMarker as latest version, you may use to confirm versionid.
aws s3api list-object-versions --bucket $BUCKET_NAME --prefix $KEY_PREFIX --query 'DeleteMarkers[?IsLatest==`true`]'
# this will actually restore all files by deleting delete marker from deleted files.
aws s3api list-object-versions --bucket $BUCKET_NAME --prefix $KEY_PREFIX --output json --query 'DeleteMarkers[?IsLatest==`true`].[Key, VersionId]' | jq -r '.[] | "--key '\''" + .[0] + "'\'' --version-id " + .[1]' | xargs -L1 aws s3api delete-object --bucket $BUCKET_NAME
stages:
- deploy
deploy_production:
stage: deploy
script:
- npm install
- npm run build --prod
- echo "Deploy to Production server"
- aws s3 sync ./dist s3://$BUCKETNAME/ --acl=public-read --delete
@thecfguy
thecfguy / bucket-public-permission.json
Created July 2, 2019 06:55
AWS bucket permission to give public read access
{
"Version": "2012-10-17",
"Id": "PublicBucketPolicy",
"Statement": [
{
"Sid": "Stmt1482880670019",
"Effect": "Allow",
"Principal": "*",
"Action": "s3:GetObject",
"Resource": "arn:aws:s3:::BUCKETNAME/*"
# Powershell script to list all files (including sub directory) under particular directory and remove last line out of it.
Get-ChildItem ".\" -Recurse -Filter *.txt |
Foreach-Object {
$lastline = Get-Content $_.FullName | select -Last 1
if ($lastline -like 'findsomestring') {
$test = Get-Content $_.FullName
$output = $test[0..($test.count - 2)]
Set-Content -Path $_.FullName -Value $output
}
@thecfguy
thecfguy / index.js
Created March 21, 2016 11:46 — forked from anonymous/index.js
Arrange labels for all kind of density
function dpToPixel(dp) {
return ( parseInt(dp) * (Titanium.Platform.displayCaps.dpi / 160));
}
// convert pixel to dp.
function pixelToDp(px,nounit) {
return ( parseInt(px) / (Titanium.Platform.displayCaps.dpi / 160)) + (nounit?0:'dp');
}
var reArrangeLable = function(){
<cfscript>
rc.date = "Mon Feb 29 2016 00:00:00 GMT+0530 (IST)";
rc.date1 = DateAdd("s", 0, rc.date);
WriteDump(var=rc); //Converted to {ts '2016-02-28 22:00:00'} instead of {ts '2016-02-28 18:30:00'}
rc.date = "Mon Feb 29 2016 00:00:00 GMT+0430 (AFT)";
rc.date1 = DateAdd("s", 0, rc.date);
WriteDump(var=rc);
</cfscript>
<cfmail to="to@test.com" from="form@test.com" subject = "Email with attachment" type="text">
<cfmailparam file="C:\Inetpub\wwwroot\worklog.pdf">
<cfmailpart type="html">
<p>Html Email content goes here </p>
</cfmailpart>
</cfmail>
<cfmail to="to@test.com" from="form@test.com" subject = "Email with attachment" type="html">
<cfmailparam file="C:\Inetpub\wwwroot\worklog.pdf">
Email body will goes here.
</cfmail>
var casper = require('casper').create();
casper.start('http://www.isummation.com/', function() {
this.echo(this.getTitle());
});
casper.run();
@thecfguy
thecfguy / handler.cfc
Last active August 29, 2015 14:02
ORM One-To-Many
component output="false" singleton{
// Default Action
property name="masterService" inject="entityService:tmaster" scope="variables";
property name="detailService" inject="entityService:tdetail" scope="variables";
function index(event,rc,prc){
var masterbean = masterService.new({col1:"master"});
var detailbean = detailService.new({col2:"detail"});
/* save with master bean