• Factory.

    KopBob        
    0 Likes0 Commentsjavascript

    currentNgModule.factory('PageTitleService', function ($rootScope) {
        return {
            updateWith: function (title) {
                $rootScope.pageTitle = title;
            }
        }
    });
  • Getting a head start on my classes' textbook

    connador        
    0 Likes0 Commentsc_cpp

    #include <stdio.h>
    #define INCHES_PER_POUND 166
    
    int main(void){
    int height, length, width, volume, weight;
    printf("Please enter the height of your box: ");
    scanf("%d", &height);
    printf("Please enter the length of your box: ");
    scanf("%d", &length);
    printf("Please enter the width of your box: ");
    scanf("%d", &width);
    
    volume = height * length * width;
    weight = (volume + INCHES_PER_POUND - 1) / INCHES_PER_POUND;
    
    printf("Dimensions: %dx%dx%d\n", height, length, width);
    printf("Volume (cubic inches): %d\n", volume);
    printf("Dimensional weight (pounds): %d\n", weight);
    
    return 0;
    }
  • The first Java function entirely written by me

    tsbgroup        
    0 Likes0 Commentsjava

    private void fill() throws Exception {
    
        //формируем xml объект
        URLReader xml = new URLReader(this.getChanelUrl());
    
        //формируем из xml объект для парсинга
        Document doc = parseXML(xml.getUrlConnection().getInputStream());
    
        // /получаем список узлов документа в виде массива
        NodeList podcastTitles = doc.getElementsByTagName("title");
    
        //инициализируем имя подкаст-ленты
        this.setName(podcastTitles.item(0).getTextContent());
    
        //получаем все подкасты из xml
        NodeList podcastItems = doc.getElementsByTagName("item");
        
        //производим само заполнение массива подкастов
        for(int i=0; i < podcastItems.getLength(); i++)
        {
            this.podcastList.add(new Podcast(podcastItems.item(i)));
        }
    
      }
  • keyboardr        
    0 Likes0 Commentsxml

    <style name="TextAppearance.Grandparents">
      <item name="allCaps">true</item>
    </style>
  • yaml translations

    MattKetmo        
    0 Likes0 Commentsyaml

    menu:
        home: "Home"
        about: "About"
        contact: "Contact"
    
    footer:
        trademark: "© me %date%"
    
    page.index:
        jumbotron:
            title: "This is Openl10n"
            paragraph: "Cras justo odio, dapibus ac facilisis in, egestas eget quam. Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet risus."
            button: "Learn more"
    
    marketing:
        item1:
            title: "Subheading 1"
            text: "Donec id elit non mi porta gravida at eget metus. Maecenas faucibus mollis interdum."
        item2:
            title: "Subheading 2"
            text: "Morbi leo risus, porta ac consectetur ac, vestibulum at eros. Cras mattis consectetur purus sit amet fermentum."
        item3:
            title: "Subheading 3"
            text: "Maecenas sed diam eget risus varius blandit sit amet non magna."
        item4:
            title: "Subheading 4"
            text: "Donec id elit non mi porta gravida at eget metus. Maecenas faucibus mollis interdum."
    
  • Heartbleed

    tarraschk        
    0 Likes0 Commentsc_cpp

    unsigned char *buffer, *bp;
        int r;
        
    		buffer = OPENSSL_malloc(1 + 2 + payload + padding);
    		bp = buffer;
    
    		*bp++ = TLS1_HB_RESPONSE;
    		s2n(payload, bp);
    		memcpy(bp, pl, payload);
    		bp += payload;
    		
    		RAND_pseudo_bytes(bp, padding);
    
    		r = dtls1_write_bytes(s, TLS1_RT_HEARTBEAT, buffer, 3 + payload + padding);
    
    		if (r >= 0 && s->msg_callback)
    			s->msg_callback(1, s->version, TLS1_RT_HEARTBEAT,
    				buffer, 3 + payload + padding,
    				s, s->msg_callback_arg);
    
    		OPENSSL_free(buffer);
  • Sass color variable

    CharlesMassry        
    0 Likes0 Commentsscss

    $primary-color: #E3E7F2;
    
    body{
      background-color: $primary-color;
    	font: 14px Helvetica, Arial, sans-serif;
    }
  • cschlisner        
    0 Likes0 Commentsjava

    class q3 {
         public static void main(String args[]){     		
    			long n = 600851475143L, i=2;
    			while (true){
    				if (i==n)
    					break;
    				else if ((n%i)==0){
    					n=n/i;
    					i=2;
    					continue;
    				}
    				else ++i;	
    			}
    			System.out.println(n);
    	   }
    }
  • Express.js app

    choochootrain        
    0 Likes0 Commentsjavascript

    var express = require("express");
    var ejs = require("ejs");
    var app = express();
    
    
    ///////////////////////////////////////////////////////////////////////////////
    // APP CONFIGURATION                                                         //
    ///////////////////////////////////////////////////////////////////////////////
    //configure logging
    app.use(express.logger());
    //make files in static folder publicly accessible
    app.use('/static', express.static(__dirname + '/static'));
    //use ejs for html templates
    app.engine('html', ejs.renderFile);
    
    
    ///////////////////////////////////////////////////////////////////////////////
    // APP ROUTES                                                                //
    ///////////////////////////////////////////////////////////////////////////////
    //default route
    app.get('/', function(req, res) {
      res.render('index.html', { });
    });
    
    app.get('/test', function(req, res) {
      res.render('test.html', { });
    });
    
    app.get('/ball', function(req, res) {
      res.render('ball.html', { });
    });
    
    ///////////////////////////////////////////////////////////////////////////////
    // RUN CONFIGURATION                                                         //
    ///////////////////////////////////////////////////////////////////////////////
    var port = Number(process.env.PORT || 5000);
    app.listen(port, function() {
        console.log("Listening on " + port);
    });
  • variadic unpacking in go

    JesseObrien        
    0 Likes0 Commentsgolang

    func unpack(s []string, vars... *string) {
       for i, str := range s {
          *vars[i] = str
       }
    }