Skip to content

Instantly share code, notes, and snippets.

View charlwillia6's full-sized avatar
🐢
Becoming Awesome

Charles Williams charlwillia6

🐢
Becoming Awesome
View GitHub Profile
@charlwillia6
charlwillia6 / .gitignore
Last active September 23, 2019 18:26 — forked from andreasonny83/.gitignore
Gitignore template for JavaScript projects
# See http://help.github.com/ignore-files/ for more about ignoring files.
# Compiled output
/dist
/tmp
/out-tsc
/build
# Runtime data
pids
@charlwillia6
charlwillia6 / check_and_remove.js
Last active October 8, 2019 20:19
JavaScript Snippets #js #es6
let unique_array = Array.from(not_unique_array
.reduce((a, b) => a.set(b, b), new Map())
).map(v => v[1]);
@charlwillia6
charlwillia6 / fiddle.css
Last active March 5, 2019 22:58
Gist and jsFiddle example #html #js #css #example #fiddle
.fiddle {
color: red;
font-weight: bolder;
}
@charlwillia6
charlwillia6 / translate.py
Last active May 26, 2023 02:21 — forked from vonNiklasson/translate.py
Management script for Django to easily run the 'makemessages'-command for all files in your Django application. #django #translations
'''
translate.py
Management script for Django to easily run the
'makemessages'-command and 'compilemessages'-command for all
files in your Django application.
Put in any registered django app in the location
<app>/management/commands/translate.py
and then use python manage.py translate
to run makemessages on all files in your project
@charlwillia6
charlwillia6 / has_changed.py
Last active March 5, 2019 21:47
Field Change - Check if a field has changed before saving a model. #django #python #view
def has_changed(instance, field):
if not instance.pk:
return False
old_value = instance.__class__._default_manager.filter(pk=instance.pk).values(field).get()[field]
return not getattr(instance, field) == old_value
@charlwillia6
charlwillia6 / batch_rename_to_lowercase.ps1
Last active October 4, 2019 14:16
Powershell Snippets #ps #snippets
Get-ChildItem "C:\Path\To\Pics" -recurse | Where {-Not $_.PSIsContainer} | Rename-Item -NewName {$_.FullName.ToLower()}
@charlwillia6
charlwillia6 / npm_uninstall.sh
Last active February 26, 2019 04:59
Uninstall package.json #shell #npm #node
# /bin/bash
npm uninstall `ls -1 node_modules | tr '/\n' ' '`
@charlwillia6
charlwillia6 / center_image.html
Last active February 26, 2019 05:00
Center images with caption aligning beneath the image. #snippet #html
<div style="display: block; text-align: center;">
<div style="display: inline-block">
<div class="wrapper" style="display: table; text-align: left">
<a href="#" target="_blank"><img alt="Wib Ami Video" src="/assets/225577/fullsize/wib_ami_video.jpg" style="display: block; text-align: center;"></a>
<div class="caption" style="display: table-caption; caption-side: bottom;">Ami: Network means an open, helping hand</div>
</div>
</div>
</div>
@charlwillia6
charlwillia6 / database_single_user.sql
Created February 21, 2017 21:10
Set SQL database to single user mode
USE master;
GO
ALTER DATABASE AdventureWorks2012
SET SINGLE_USER
WITH ROLLBACK IMMEDIATE;
GO
ALTER DATABASE AdventureWorks2012
SET READ_ONLY;
GO
ALTER DATABASE AdventureWorks2012