Skip to content

Instantly share code, notes, and snippets.

@lamarmarshall
lamarmarshall / django_start
Created November 22, 2015 18:59
#django_start #django the first commands to start up django
1) virtualenv $name
2) pip install django
3)source bin/activate
4) django-admin startproject $name
5)django-admin startapp $name
@lamarmarshall
lamarmarshall / angular form error message.html
Created December 2, 2015 03:36
angular form error messages
<p>
<label for="email">Email</label>
<input type="email" ng-model="formModel.email" name="email" required="required"
ng-class="{green: theForm.email.$valid ,
red: !theForm.email.$valid && !theForm.$pristine
}">
<p class="red" ng-show="theForm.email.$error.required && !theForm.$pristine">
email is required
</p>
@lamarmarshall
lamarmarshall / angular_form_submitted
Last active December 2, 2015 03:46
angular form submited
<p>
<label for="email">Email</label>
<input type="email" ng-model="formModel.email" name="email" required="required"
ng-class="{green: theForm.email.$valid ,
red: !theForm.email.$valid && (!theForm.$pristine || theForm.$submitted)
}">
<p class="red" ng-show="theForm.email.$error.required && !theForm.$pristine">
email is required
</p>
@lamarmarshall
lamarmarshall / angular_custom_validation
Created December 2, 2015 03:58
angular custom validation
<p>
<label for="full_name">Full Name</label>
<!-- each form must have name and html validation -->
<!-- must have ng-class variable object with classes like this -->
<input type="text" ng-model="formModel.fullname" name="full_name" required="required"
ng-pattern="^[a-zA-Z][a-zA-Z0-9-_\.]{1,20}$"
ng-class="{
green: theForm.full_name.$valid ,
red: !theForm.full_name.$valid && !theForm.$pristine
@lamarmarshall
lamarmarshall / nginx location
Created December 7, 2015 17:50
nginx location
location = / {
[ configuration A ]
}
location / {
[ configuration B ]
}
location /documents/ {
[ configuration C ]
@lamarmarshall
lamarmarshall / angular change brackets
Last active December 22, 2015 13:58
angular change bracke
var app = angular.module(myapp,[]).config(function($interpolateProvider){
$interpolateProvider.startSymbol('[[').endSymbol(']]');
});
@lamarmarshall
lamarmarshall / python django pillow thumbnail.py
Created December 24, 2015 02:27
python django pillow thumbnail resize
MEDIA_ROOT = os.getcwd()+'/media/'
THUMBNAILS = MEDIA_ROOT+"thumbnails/"
ct = request.FILES["file"].content_type
ext = file_ext(ct)
handle_uploaded_file(request.FILES['file'], generated_name+ext )
thumbnail(MEDIA_ROOT+generated_name+ext, THUMBNAILS+generated_name+ext)
@lamarmarshall
lamarmarshall / swift progress indicator
Last active March 3, 2017 04:35
swift spinner progressbar indicator
var spinning: Bool = false
var spinner = UIActivityIndicatorView()
@IBAction func spin(_ sender: Any) {
if !spinning {
spinner = UIActivityIndicatorView(frame: CGRect(x: 0, y: 0, width: 200, height: 200 ) )
spinner.center = self.view.center
spinner.hidesWhenStopped = true
@lamarmarshall
lamarmarshall / args-math.go
Last active October 15, 2017 00:52
golang ,eval parse math , commanf line arguments
package main
import (
"fmt"
"os"
"strings"
"github.com/apaxa-go/eval"
)
@lamarmarshall
lamarmarshall / loops.go
Created October 15, 2017 00:51
golang loops, arrays and maps
package main
import (
"fmt"
)
func main() {
for i := 1; i <= 10; i++ {
fmt.Printf("%v -- %v \n", "super", "love")
}