Skip to content

Instantly share code, notes, and snippets.

@codegirl-007
codegirl-007 / buttons.elm
Created December 28, 2020 05:46
Solution to Elm button exercise
module Main exposing (..)
-- Press buttons to increment and decrement a counter.
--
-- Read how it works:
-- https://guide.elm-lang.org/architecture/buttons.html
--
import Browser
@codegirl-007
codegirl-007 / textfields.elm
Created December 28, 2020 05:44
Solution to Elm text field exercise
-- A text input for reversing text. Very useful!
--
-- Read how it works:
-- https://guide.elm-lang.org/architecture/text_fields.html
--
import Browser
import Html exposing (Html, Attribute, div, input, text)
import Html.Attributes exposing (..)
import Html.Events exposing (onInput)
@codegirl-007
codegirl-007 / jasmine-cheat.js
Created May 8, 2016 08:10
Jasmine cheatsheet
describe('built-in matchers', function() {
describe('toBeTruthy', function() {
it('passes if subject is true', function() {
expect(true).toBeTruthy();
expect(false).not.toBeTruthy();
});
});
describe('toBeFalsy', function() {
it('passes if subject is false', function() {
@codegirl-007
codegirl-007 / name.js
Last active May 8, 2016 03:59
Setting up Browserify and Jasmine with NPM
exports.getName = function(name) {
return name;
}
@codegirl-007
codegirl-007 / git-commands.sh
Last active November 6, 2015 02:59
Git Commandline basic
# create a new branch
git checkout -b branch-name
# checkout an existing branch
git checkout branch name
# pull changes from branch-a into current-branch
git checkout branch-a
git pull --rebase # get all the latest changes from branch-a
git checkout current-branch
@codegirl-007
codegirl-007 / gist:5a4feb78e138c5579cdd
Created May 28, 2015 04:02
Separate requirejs configs from app
require.config({
deps: ['app'], //just make your app file a dependency
paths: {
//...
}
});
@codegirl-007
codegirl-007 / gist:43a710b0edf6682b0854
Created April 13, 2015 19:10
Duplicate document in Mongo
var copy = db.collection.findOne({_id : ObjectId("552c0709d07e391454f649df")},{_id:0});
for (var i = 0; i< 10; i++){
db.collection.insert(copy);
}
@codegirl-007
codegirl-007 / gist:23d2856926cdebcab453
Created April 8, 2015 23:18
Mongo Search & Replace
var cursor = db.collection.find(url: /http/)
while (cursor.hasNext()) {
var x = cursor.next();
print("Before: "+x['url']);
x['url'] = x['url'].replace('http', 'https');
print("After: "+x['url']);
db.collection.update({_id : x._id}, x);
}
@codegirl-007
codegirl-007 / gist:88fa2dd8a777cf82f4d9
Last active August 29, 2015 14:17
Return JSON with EBean and Play
//return a collection of items
public static Result getAssets() {
List<Asset> asset = Ebean.find(Asset.class)
.findList();
return ok(toJson(asset));
}
//or return a single item with the id being passed as a url param
public static Result getAsset(Integer id) {
@codegirl-007
codegirl-007 / gist:9c7f7458387f9310b7bd
Last active August 29, 2015 14:17
Create a ManyToMany relationship in EBean
public class EntityList extends Model {
@Id
private Integer id;
@Constraints.Required
public String title;
@Constraints.Required
public String type;