Skip to content

Instantly share code, notes, and snippets.

View stewones's full-sized avatar
🐠
Ship! Ship! Ship!

Stewan Silva stewones

🐠
Ship! Ship! Ship!
View GitHub Profile
function calculo() {
var total1 = 0, total2 = 0, total3 = 0, total4 = 0;
if (document.cel1.Locar1.checked == true) {
total1 = 3999;
if (document.cel1.cel1d == "Dummy") {
total1 = 3799.05;
}
else if (document.cel1.cel1n == "Normal") {
total1 = 3599.1;
@stewones
stewones / while.c
Created April 13, 2016 03:33
exemplo de while em C
# include <stdio.h>
# include <stdlib.h>
//
// O sistema de avaliação de uma determinada disciplina obedece os seguintes criterios
// - Durante o semestre sao dada 3 notas
// - A nota final é a media aritimetica
// - é considerado aprovado o aluno que tiver a media final maior ou igual a 60 e que tenha um numero minimo de 40 presenças
// Leia um conjunto de dados contendo o numero de matricula, as 3 notas e a frequencia ate que o numero digitado seja 0
// Calcule:
// - a nota final de cada aluno e sua situação (aprovado/reprovado)
@stewones
stewones / ionic-windows-error.sh
Last active February 6, 2016 01:14
ionic windows error
app.bundle.js 2.59 MB 0 [emitted] main
[0] multi main 76 bytes {0} [built]
+ 356 hidden modules
√ Webpack complete
Running command: "C:\Program Files\nodejs\node.exe" c:\dev\cutePuppyPics\hooks\
fter_prepare\010_add_platform_class.js c:\dev\cutePuppyPics
add to body class: platform-android
Running command: cmd "/s /c "c:\dev\cutePuppyPics\platforms\android\cordova\run
var express = require('express');
var compression = require('compression');
var prerender = require('prerender-node');
var bodyParser = require('body-parser');
var Schema = mongoose.Schema;
var app = express();
// Here we require the prerender middleware that will handle requests from Search Engine crawlers
// We set the token only if we're using the Prerender.io service
app.use(require('prerender-node')
@stewones
stewones / class.js
Last active August 26, 2015 18:40 — forked from matheusdavidson/class.js
// Controller
Insc.findById('55db841e16f87bd00bfec6df').populate('orderInsc.items.insc').exec(function(err, insc){
console.log('insc', insc);
});
// Models
var InscSchema = new Schema({
orderInsc: {
type: Schema.Types.ObjectId,
ref: 'Order'
@stewones
stewones / angular service sample.js
Last active August 29, 2015 14:24
angular service sample
angular.controller('EventCtrl', /*@ngInject*/ function EventCtrl(Event) {
var vm = this;
//work with Event!
var eventInstance = new Event({_id: 123, title:'Awesome',desc:'Okd!!'});
console.log(eventInstance);
vm.event = eventInstance;
//call instance behaviors
eventInstance.save();
//npm install b64url
//A signed_request for testing:
//WGvK-mUKB_Utg0l8gSPvf6smzacp46977pTtcRx0puE.eyJhbGdvcml0aG0iOiJITUFDLVNIQTI1NiIsImV4cGlyZXMiOjEyOTI4MjEyMDAsImlzc3VlZF9hdCI6MTI5MjgxNDgyMCwib2F1dGhfdG9rZW4iOiIxNTI1NDk2ODQ3NzczMDJ8Mi5ZV2NxV2k2T0k0U0h4Y2JwTWJRaDdBX18uMzYwMC4xMjkyODIxMjAwLTcyMTU5OTQ3NnxQaDRmb2t6S1IyamozQWlxVldqNXp2cTBmeFEiLCJ1c2VyIjp7ImxvY2FsZSI6ImVuX0dCIiwiY291bnRyeSI6ImF1In0sInVzZXJfaWQiOiI3MjE1OTk0NzYifQ
function parse_signed_request(signed_request, secret) {
encoded_data = signed_request.split('.',2);
// decode the data
sig = encoded_data[0];
json = base64url.decode(encoded_data[1]);
data = JSON.parse(json); // ERROR Occurs Here!
@stewones
stewones / gist:5b90e41b6d7e27ad2e0a
Last active August 29, 2015 14:20
nested funcions
'use strict';
class FinderCtrl {
/*@ngInject*/
constructor() {
if (!UserFactory.isAuthed()) return;
var vm = this;
//
// SEO
//
layout.setTitle(setting.title);
//factory
app.factory('dataLoad', function($http) {
return {
getData: function() {
return $http.get('data-json.php');
}
}
});
//controller
@stewones
stewones / gulpfile.js
Last active August 29, 2015 14:17
simple gulp task for angular seo static servers
var gulp = require('gulp');
//especificando grupo de tarefas
gulp.task('crawl-serve', ['crawl-page1','crawl-page2']);
//definindo as tarefas
//a array do segundo parametro é opcional, serve pra especificar após quais tarefas esta tarefa deverá rodar
//tarefa 1
gulp.task('crawl-page1', [], function() {