text:
language = "en"
}

@ARTICLE{Dal_Maso2016-ol,
    title = "Distance between rotator cuff footprints and the acromion,
              coracoacromial ligament, and coracoid process during dynamic arm
              elevations: Preliminary observations",
    author = "Dal Maso, Fabien and Blache, Yoann and Raison, Maxime and Arndt,
              Anton and Begon, Micka{\"e}l",
    abstract = "BACKGROUND: The objective of this study was to provide
              preliminary measures of the distance between the supraspinatus,
              infraspinatus, and subscapularis footprints and the acromion,
              coracoacromial ligament, and coracoid process, during dynamic arm
              elevations through the entire range-of-motion. METHODS: Two
              healthy men performed maximum adduction, flexion, abduction, and
              extension with the arm internally, neutrally, and externally
              rotated. The distance between each rotator cuff footprint and the
              acromion, coracoacromial ligament, and coracoid process was
              measured from glenohumeral kinematics obtained from markers
              fitted to intracortical pins combined with the scapular and
              humeral 3D geometry obtained from CT-scan. RESULTS: All
              footprints moved to be less than 10 mm to the acromion,
              coracoacromial ligament and coracoid process. They got closer to
              the acromion than to the other parts of the coracoacromial arch.
              The acromion-supraspinatus and acromion-infraspinatus distances
              were minimal during abduction and flexion. The
              acromion-subscapularis distance was minimal when the arm was in
              external and neutral rotation during both adduction and flexion.
              CONCLUSIONS: The present study provides benchmark results of the
              distance between the rotator cuff footprints and the
              coracoacromial arch that may guide future clinical research.
              Pressure transducers should be positioned throughout the
              coracoacromial arch to provide comprehensive assessment of the
              compression undergone by the rotator cuff tendons. Common
              shoulder examination tests, that require flexion and internal
              rotation movements, may be refined since the supraspinatus
              footprint was the closest to the coracoacromial arch during
              abduction. Larger scale investigations may be needed to identify
              more accurate shoulder examination tests.",
    journal = "Man. Ther.",
    volume = 25,
    pages = "94--99",
    month = sep,
    year = 2016,
    keywords = "Acromiohumeral distance; Coracoacromial arch; Intracortical pins;
              Subacromial impingement
              syndrome;Ergonomics;Phd/Ergonomics/General",
    language = "en"
}

@ARTICLE{Cote2012-hn,
    title = "A critical review on physical factors and functional
              characteristics that may explain a sex/gender difference in
              work-related neck/shoulder disorders",
    author = "C{\^o}t{\'e}, J N",
    abstract = "UNLABELLED: The objective of this paper is to critically review
              recent literature on physical and functional sex/gender (s/g)
              differences, with focus on physical determinants associated with
              neck/shoulder musculoskeletal injuries. It is well known that
              there are s/g differences in anthropometrical and functional body
              characteristics (e.g. size and strength). However, s/g
              differences may be wrongly attributed if data analysis does not
              include appropriate corrections (e.g. by strength for endurance).
              Recent literature on motor control shows that there may indeed be
              s/g differences in muscle coordination and movement strategies
              during upper limb tasks that are not currently explained by
              methodological inadequacies. Moreover, recent studies have shown
              differences between men and women in sensory hypersensitivity
              characteristics associated with neck/shoulder injuries. Taken
              together, the literature points to the importance of accounting
              for possible s/g differences at all levels of the biopsychosocial
              system in order to better understand sex- and gender-specific
              issues relevant to workplace health. PRACTITIONER SUMMARY: This
              article critically reviews recent literature and a conceptual
              model highlighting s/g differences in physical and functional
              characteristics related to neck/shoulder musculoskeletal
              disorders (NSMSD). Findings have implications on understanding
              how personal factors may affect NSMSD risk. With better
              understanding, practitioners can make more appropriate decisions
              to prevent work-related NSMSD.",
    journal = "Ergonomics",
    volume = 55,
    number = 2,
    pages = "173--182",
    year = 2012,
    keywords = "Article
              lu;Ergonomics;synt\_bmc;synth\_erg;Phd/Ergonomics/Men-women",
    language = "en"
}

@ARTICLE{Wu2016-kw,
    title = "Subject-specific musculoskeletal modeling in the evaluation of
              shoulder muscle and joint function",
    author = "Wu, Wen and Lee, Peter V S and Bryant, Adam L and Galea, Mary and
              Ackland, David C",
    abstract = "Upper limb muscle force estimation using Hill-type muscle models
              depends on musculotendon parameter values, which cannot be
              readily measured non-invasively. Generic and scaled-generic
              parameters may be quickly and easily employed, but these
              approaches do not account for an individual subject's joint
              torque capacity. The objective of the present study was to
              develop a subject-specific experimental testing and modeling
              framework to evaluate shoulder muscle and joint function during
              activities of daily living, and to assess the capacity of generic
              and scaled-generic musculotendon parameters to predict muscle and
              joint function. Three-dimensional musculoskeletal models of the
              shoulders of 6 healthy subjects were developed to calculate
              muscle and glenohumeral joint loading during abduction, flexion,
              horizontal flexion, nose touching and reaching using
              subject-specific, scaled-generic and generic musculotendon
              parameters. Muscle and glenohumeral joint forces calculated using
              generic and scaled-generic models were significantly different to
              those of subject-specific models (p<0.05), and task dependent;
              however, scaled-generic model calculations of shoulder
              glenohumeral joint force demonstrated better agreement with those
              of subject-specific models during abduction and flexion. Muscles
              in generic musculoskeletal models operated further from the
              plateau of their force-length curves than those of scaled-generic
              and subject-specific models, while muscles in subject-specific
              models operated over a wider region of their force length curves
              than those of the generic or scaled-generic models, reflecting
              diversity of subject shoulder strength. The findings of this
              study suggest that generic and scaled-generic musculotendon
              parameters may not provide sufficient accuracy in prediction of
              shoulder muscle and joint loading when compared to models that
              employ subject-specific parameter-estimation approaches.",
    journal = "J. Biomech.",
    volume = 49,
    number = 15,
    pages = "3626--3634",
    month = nov,
    year = 2016,
    keywords = "Biomechanical model; Glenohumeral; Musculotendon parameters;
              Upper limb;Biomechanics;synt\_bmc;Phd/Biomechanics/MSQ",
    language = "en"
}

@ARTICLE{Pizzolato2015-gm,
    title = "{CEINMS}: A toolbox to investigate the influence of different
              neural control solutions on the prediction of muscle excitation
              and joint moments during dynamic motor tasks",
    author = "Pizzolato, Claudio and Lloyd, David G and Sartori, Massimo and
              Ceseracciu, Elena and Besier, Thor F and Fregly, Benjamin J and
              Reggiani, Monica",
    abstract = "Personalized neuromusculoskeletal (NMS) models can represent the
              neurological, physiological, and anatomical characteristics of an
              individual and can be used to estimate the forces generated
              inside the human body. Currently, publicly available software to
              calculate muscle forces are restricted to static and dynamic
              optimisation methods, or limited to isometric tasks only. We have
              created and made freely available for the research community the
              Calibrated EMG-Informed NMS Modelling Toolbox (CEINMS), an
              OpenSim plug-in that enables investigators to predict different
              neural control solutions for the same musculoskeletal geometry
              and measured movements. CEINMS comprises EMG-driven and
              EMG-informed algorithms that have been previously published and
              tested. It operates on dynamic skeletal models possessing any
              number of degrees of freedom and musculotendon units and can be
              calibrated to the individual to predict measured joint moments
              and EMG patterns. In this paper we describe the components of
              CEINMS and its integration with OpenSim. We then analyse how
              EMG-driven, EMG-assisted, and static optimisation neural control
              solutions affect the estimated joint moments, muscle forces, and
              muscle excitations, including muscle co-contraction.",
    journal = "J. Biomech.",
    volume = 48,
    number = 14,
    pages = "3929--3936",
    month = nov,
    year = 2015,
    keywords = "EMG-driven; EMG-informed; Neuromusculoskeletal modelling; Static
              optimisation;Phd/Biomechanics/MSQ",
    language = "en"
}

@ARTICLE{Blache2015-xe,
    title = "Superficial shoulder muscle co-activations during lifting tasks:
              Influence of lifting height, weight and phase",
    author = "Blache, Y and Dal Maso, F and Desmoulins, L and Plamondon, A and
              Begon, M",
    abstract = "This study aimed to assess the level of co-activation of the
              superficial shoulder muscles during lifting movement. Boxes
              containing three different loads (6, 12, and 18 kg) were lifted
              by fourteen subjects from the waist to shoulder or eye level. The
              3D kinematics and electromyograms of the three deltoids,
              latissimus dorsi and pectoralis major were recorded. A
              musculoskeletal model was used to determine direction of the
              moment arm of these muscles. Finally an index of muscle
              co-activation named the muscle focus was used to evaluate the
              effects of lifting height, weight lifted and phase (pulling,
              lifting and dropping phases) on superficial shoulder muscle
              coactivation. The muscle focus was lower (more co-contraction)
              during the dropping phase compared to the two other phases
              (-13\%, p<0.001). This was explained by greater muscle
              activations and by a change in the direction of the muscle moment
              arm as a function of glenohumeral joint position. Consequently,
              the function of the shoulder superficial muscles varied with
              respect to the glenohumeral joint position. To increase the
              superficial muscle coactivation during the dropping phase may be
              a solution to increase glenohumeral joint stiffness.",
    journal = "J. Electromyogr. Kinesiol.",
    volume = 25,
    number = 2,
    pages = "355--362",
    month = apr,
    year = 2015,
    keywords = "Co-contraction; Electromyography; Glenohumeral joint; Moment arm;
              Muscle focus;Biomechanics;Phd/Biomechanics/EMG",
    language = "en"
}

@ARTICLE{Kim2003-lf,
    title = "Measurement of physical work capacity during arm and shoulder
              lifting at various shoulder flexion and ad/abduction angles",
    author = "Kim, Jung-Yong and Chung, Min-Keun and Park, Ji-Soo",
    abstract = "Abstract The purpose of this study was to provide information on
              physical work capacity during arm and shoulder lifting at various
              shoulder flexion and ad/abduction angles. We measured the maximum
              voluntary contractions (MVCs) in 20 male participants during
              controlled one-arm lifting. The lifting involved upward motion of
              the scapula at various shoulder angles. Simultaneously, the
              electromyographic (EMG) activity of 3 shoulder muscles and
              psychophysical workload were also recorded. The various
              measurements were compared to provide a multidimensional
              assessment of the physical work capacity of the shoulder at
              various working angles. In particular, 90 and 120 degrees of
              flexion, 30 degrees of adduction, and 90 degrees of abduction
              were found to be the most vulnerable angles based on the measured
              MVCs. The average root mean square value of the EMG increased
              most significantly at 90 to 150 degrees of flexion and at 30 and
              60 degrees of abduction. Slightly different measurements were
              compared to validate the results. In addition, a 3-D static
              biomechanical model was used to show whether the estimated
              shoulder workload matched the measured physical capacity of the
              shoulder. In conclusion, these results may help ergonomists to
              identify shoulder angles associated with a relatively high risk
              of injury, and to match the workload with the physical capacity
              of the shoulder. Task-specific information on shoulder work
              capacity is needed in the manufacturing and shipbuilding
              industries to protect workers from acute injuries and cumulative
              trauma disorders of the shoulder. Experimental results provide
              various data on shoulder work capacity during realistic
              multijoint arm and shoulder lifting, and should help lead to
              improvements in workplace ergonomic design. ? 2003 Wiley
              Periodicals, Inc. Hum Factors Man 13: 153?163, 2003.",
    journal = "Hum. Factors Man.",
    volume = 13,
    number = 2,
    pages = "153--163",
    month = 21,
    year = 2003,
    keywords = "Phd/Biomechanics/MSQ"
}

@ARTICLE{Bergmann2007-zj,
    title = "In vivo glenohumeral contact forces---Measurements in the first
              patient 7 months postoperatively",
    author = "Bergmann, G and Graichen, F and Bender, A and K{\"a}{\"a}b, M and
              Rohlmann, A and Westerhoff, P",
    abstract = "Knowledge of forces in the glenohumeral joint is essential for
              understanding normal and pathologic shoulder function. It forms
              the basis for performing fracture treatment or joint replacement
              surgery, for optimizing implant design and fixation and for
              improving and verifying analytical biomechanical models of the
              shoulder. An instrumented shoulder implant with telemetric data
              transmission was developed to measure six components of joint
              contact forces and moments. A patient with humeral head arthrosis
              achieved good joint function after its implantation. During the
              first 7 postoperative months, the contact force remained below
              100\% BW (percent body weight) for most activities of daily
              living. It ranged up to 130\% BW for arm positions close to the
              limits of motion or when acting against external resistance. When
              the patient tried to turn a blocked steering wheel with maximum
              effort, the force rose to about 150\% BW, the highest level
              observed thus far. Of great interest were the force directions
              relative to the humerus, especially those in the sagittal plane,
              which were not greatly influenced by the type of exercise, the
              arm position or the external resistance. The moments due to
              friction in the joint reached 5.2Nm. The friction-induced shift
              of contact forces relative to the implant head centre ranged up
              to 6.3mm. These first worldwide in vivo measurements of
              glenohumeral contact forces are being continued in more patients
              and for longer postoperative times.",
    journal = "J. Biomech.",
    volume = 40,
    number = 10,
    pages = "2139--2149",
    month = jan,
    year = 2007,
    keywords = "Shoulder joint; Arthroplasty; Load; Contact forces; Measurement;
              Telemetry; In vivo; Biomechanics;synt\_bmc"
}

@ARTICLE{Plamondon2014-xe,
    title = "Sex differences in lifting strategies during a repetitive
              palletizing task",
    author = "Plamondon, A and Larivi{\`e}re, C and Denis, D and St-Vincent, M
              and Delisle, A and {IRSST MMH Research Group}",
    abstract = "Forty-five manual material handlers (15 females, 15 expert males
              and 15 novice males) performed series of box transfers under
              conditions similar to those of large distribution centers. The
              objective of the study was to verify whether sex differences in
              joint motions and in back loading variables (L5/S1 moments) exist
              during multiple box transfers. The task consisted in transferring
              24 15-kg boxes from one pallet to another (4 layers of boxes; 6
              boxes/layer: 3 in the front row, 3 in the back) at a
              self-determined pace and then at an imposed pace of 9 lifts/min.
              Full-body 3D kinematic data were collected as well as external
              foot forces. A dynamic 3D linked segment model was used to
              estimate the net moments at L5/S1. The results show that the peak
              L5/S1 moment during lifting for females was significantly lower
              than for males, but once normalized to body size the difference
              disappeared. In general, the female workers were very close to
              the posture adopted by the novice males at the instant of the
              peak resultant moment. However, females were closer to the box
              than the male workers. One major sex difference was seen when
              lifting from the ground, with the use of interjoint coordination
              analyses. Female workers showed a sequential motion initiated by
              the knees, followed by the hip and the back, while expert males
              showed a more synchronized motion. The lifting strategy of
              females likely stretches lumbar spine passive tissues, which in
              turn put them at greater risk of back injuries. As observed in
              our previous studies, these differences between expert males,
              novice males and females are especially notable when the box is
              lifted from the ground.",
    journal = "Appl. Ergon.",
    volume = 45,
    number = 6,
    pages = "1558--1569",
    month = nov,
    year = 2014,
    keywords = "Lifting; Manual material handling; Sex;Article
              lu;Ergonomics;synth\_erg;Phd/Ergonomics/Men-women",
    language = "en"
}

@ARTICLE{Ema2018-cd,
    title = "Effects of sex and joint action on voluntary activation",
    author = "Ema, Ryoichi and Suzuki, Momoka and Kawaguchi, Emi and Saito, Itaru and Akagi, Ryota",
    journal = "PeerJ",
    volume = 6,
    pages = "e5968",
    month = nov,
    year = 2018,
    language = "en"
}

@ARTICLE{Inglis2013-uq,
    title = "Sex-related differences in maximal rate of isometric torque development",
    author = "Inglis, J Greig and Vandenboom, Rene and Gabriel, David A",
    journal = "J. Electromyogr. Kinesiol.",
    volume = 23,
    number = 6,
    pages = "1289--1294",
    month = dec,
    year = 2013,
    language = "en"
}

license_type: permissive

branch_name: refs/heads/master

extension: bib


text:
package apiExamples

import (
	"os"
	"time"

	"github.com/ChimeraCoder/anaconda"
	"github.com/gobuffalo/buffalo"
	"github.com/niranjan92/go-hackathon-starter/render"
	"github.com/pkg/errors"
)

var twitterAPI *anaconda.TwitterApi

func init() {
	anaconda.SetConsumerKey(os.Getenv("TWITTER_CONSUMER_KEY"))
	anaconda.SetConsumerSecret(os.Getenv("TWITTER_CONSUMER_SECRET"))
	twitterAPI = anaconda.NewTwitterApi(os.Getenv("TWITTER_API_TOKEN"), os.Getenv("TWITTER_API_SECRET"))
}

const twitterTimeout = 5 * time.Second

// TwitterHandler is a default handler to serve up samples for Github api
func TwitterHandler(c buffalo.Context) error {
	query := "#tesla"
	searchResult, err := twitterAPI.GetSearch(query, nil)
	if err != nil {
		c.Set("errors", err)
		return errors.WithStack(err)
	}
	tweets := []string{}
	for _, tweet := range searchResult.Statuses {
		if tweet.RetweetedStatus == nil {
			tweets = append(tweets, tweet.Text)
		}
	}
	c.Set("query", query)
	c.Set("tweets", tweets)
	return c.Render(200, render.R.HTML("api-examples/twitter.html"))
}

license: MIT

gha_license_id: MIT

gha_language: Go

extension: go


text:
// Copyright (c) 2017 Femtowiki authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

package main

import (
	"flag"
	"fmt"
    "github.com/eyedeekay/sam-forwarder/config"
	"github.com/s-gv/femtowiki/models"
	"github.com/s-gv/femtowiki/models/db"
	"github.com/s-gv/femtowiki/views"
	"golang.org/x/crypto/ssh/terminal"
	"log"
	"net/http"
	"net/http/fcgi"
	"syscall"
	"time"
)

func getCreds() (string, string) {
	var userName string
	fmt.Printf("Username: ")
	fmt.Scan(&userName)

	fmt.Printf("Password: ")
	password, err := terminal.ReadPassword(int(syscall.Stdin))
	fmt.Printf("\n")
	if err != nil {
		fmt.Printf("[ERROR] %s\n", err)
		return "", ""
	}
	if len(password) < 8 {
		fmt.Printf("[ERROR] Password should have at least 8 characters.\n")
		return "", ""
	}

	fmt.Printf("Password (again): ")
	password2, err := terminal.ReadPassword(int(syscall.Stdin))
	fmt.Printf("\n")
	if err != nil {
		fmt.Printf("[ERROR] %s\n", err)
	}

	pass := string(password)
	pass2 := string(password2)
	if pass != pass2 {
		fmt.Printf("[ERROR] The two psasswords do not match.\n")
		return "", ""
	}

	return userName, pass
}

func main() {
	log.SetFlags(log.LstdFlags | log.Lshortfile)

	dsn := flag.String("dsn", "femtowiki.sqlite3", "Data source name")
	dbDriver := flag.String("dbdriver", "sqlite3", "DB driver name")
	addr := flag.String("addr", ":9123", "Port to listen on")
	shouldMigrate := flag.Bool("migrate", false, "Migrate DB")
	createSuperUser := flag.Bool("createsuperuser", false, "Create superuser (interactive)")
	createUser := flag.Bool("createuser", false, "Create user. Optional arguments: <username> <password> <email>")
	changePasswd := flag.Bool("changepasswd", false, "Change password")
	deleteSessions := flag.Bool("deletesessions", false, "Delete all sessions (logout all users)")
	fcgiMode := flag.Bool("fcgi", false, "Fast CGI rather than listening on a port")
    usei2p := flag.Bool("usei2p", false, "Forward the service to the i2p network as an eepSite")
	i2pconf := flag.String("i2pini", "./contrib/tunnels.femtowiki.conf", "i2p tunnel configuration file to use")

	flag.Parse()

    if *usei2p {
		if i2pforwarder, i2perr := i2ptunconf.NewSAMForwarderFromConfig(*i2pconf, "127.0.0.1", "7656"); i2perr != nil {
			fmt.Printf("Error creating i2p tunnel from config, %s", i2perr.Error())
			return
		} else {
			*addr = i2pforwarder.Target()
			fmt.Printf("Serving eepSite on, %s", i2pforwarder.Base32())
			go i2pforwarder.Serve()
		}
	}

	db.Init(*dbDriver, *dsn)

	if *shouldMigrate {
		models.Migrate()
		return
	}

	if models.IsMigrationNeeded() {
		log.Fatalf("[ERROR] DB migration needed.\n")
	}

	if *createSuperUser {
		fmt.Printf("Creating superuser...\n")
		userName, pass := getCreds()
		if userName != "" && pass != "" {
			if err := models.CreateSuperUser(userName, pass); err != nil {
				fmt.Printf("Error creating superuser: %s\n", err)
			}
		}
		return
	}

	if *createUser {
		args := flag.Args()
		var username, passwd, email string
		if len(args) >= 2 {
			username = args[0]
			passwd = args[1]
		} else {
			username, passwd = getCreds()
		}
		if len(args) >= 3 {
			email = args[2]
		}
		if username != "" && passwd != "" {
			if err := models.CreateUser(username, passwd, email, false); err != nil {
				fmt.Printf("Error creating user: %s\n", err)
			}
		} else {
			fmt.Printf("Error: Username and password cannot be blank.\n")
		}
		return
	}

	if *changePasswd {
		userName, pass := getCreds()
		if userName != "" && pass != "" {
			if err := models.UpdateUserPasswd(userName, pass); err != nil {
				fmt.Printf("Error changing password: %s\n", err)
			}
		}
		return
	}

	if *deleteSessions {
		db.Exec(`DELETE FROM sessions;`)
		return
	}

	mux := http.NewServeMux()

	mux.HandleFunc("/", views.PagesHandler)

	mux.HandleFunc("/static/css/femtowiki.css", views.StyleHandler)

	mux.HandleFunc("/static/js/femtowiki.js", views.ScriptHandler)

	mux.HandleFunc("/favicon.ico", views.FaviconHandler)

	mux.HandleFunc("/login", views.LoginHandler)
	mux.HandleFunc("/signup", views.SignupHandler)
	mux.HandleFunc("/changepass", views.ChangepassHandler)
	mux.HandleFunc("/forgotpass", views.ForgotpassHandler)
	mux.HandleFunc("/resetpass", views.ResetpassHandler)
	mux.HandleFunc("/logout", views.LogoutHandler)
	mux.HandleFunc("/logoutall", views.LogoutAllHandler)

	mux.HandleFunc("/profile", views.ProfileHandler)
	mux.HandleFunc("/profile/update", views.ProfileUpdateHandler)
	mux.HandleFunc("/profile/ban", views.ProfileBanHandler)
	mux.HandleFunc("/profile/unban", views.ProfileUnbanHandler)

	mux.HandleFunc("/admin", views.AdminHandler)
	mux.HandleFunc("/admin/config", views.AdminConfigUpdateHandler)
	mux.HandleFunc("/admin/header", views.AdminHeaderUpdateHandler)
	mux.HandleFunc("/admin/footer", views.AdminFooterUpdateHandler)
	mux.HandleFunc("/admin/nav", views.AdminNavUpdateHandler)
	mux.HandleFunc("/admin/illegalnames", views.AdminIllegalNamesUpdateHandler)
	mux.HandleFunc("/admin/users", views.AdminUserHandler)
	mux.HandleFunc("/admin/groups", views.AdminGroupHandler)
	mux.HandleFunc("/admin/groups/new", views.AdminGroupCreateHandler)
	mux.HandleFunc("/admin/groups/delete", views.AdminGroupDeleteHandler)
	mux.HandleFunc("/admin/groupmembers", views.AdminGroupMembersHandler)
	mux.HandleFunc("/admin/groupmembers/new", views.AdminGroupMemberCreateHandler)
	mux.HandleFunc("/admin/groupmembers/delete", views.AdminGroupMemberDeleteHandler)
	mux.HandleFunc("/admin/pagemaster", views.AdminPageMasterGroupHandler)
	mux.HandleFunc("/admin/filemaster", views.AdminFileMasterGroupHandler)

	mux.HandleFunc("/pages/", views.PagesHandler)
	mux.HandleFunc("/newpage", views.PageCreateHandler)
	mux.HandleFunc("/editpage", views.PageEditHandler)

	mux.HandleFunc("/files/", views.FilesHandler)
	mux.HandleFunc("/newfile", views.FileCreateHandler)
	mux.HandleFunc("/editfile", views.FileUpdateHandler)

	mux.HandleFunc("/search", views.SearchHandler)

	if *fcgiMode {
		fcgi.Serve(nil, mux)
		return
	}

	srv := &http.Server{
		Handler:      mux,
		Addr:         *addr,
		WriteTimeout: 30 * time.Second,
		ReadTimeout:  30 * time.Second,
		IdleTimeout:  120 * time.Second,
	}

	log.Println("[INFO] Starting femtowiki at", *addr)
	err := srv.ListenAndServe()
	if err != nil {
		log.Panicf("[ERROR] %s\n", err)
	}
}

repository: eyedeekay/femtowiki

repo_name: eyedeekay/femtowiki


text:
require libpng_${PV}.bb
inherit native
FILESDIR = "${@os.path.dirname(bb.data.getVar('FILE',d,1))}/libpng-${PV}"
DEPENDS = "zlib-native"

INHIBIT_NATIVE_STAGE_INSTALL = "1"

do_stage_append() {
        cp libpng.pc libpng12.pc
        install -m 644 png.h ${STAGING_INCDIR}/png.h
        install -m 644 pngconf.h ${STAGING_INCDIR}/pngconf.h
        oe_libinstall -so libpng12 ${STAGING_LIBDIR}/
        ln -sf libpng12.so ${STAGING_LIBDIR}/libpng.so
}

repository: jdegges/gumstix-pip-oe

repo_name: jdegges/gumstix-pip-oe

extension: bb


text:
package command

import (
	"flag"
	"fmt"
	"sort"
	"strconv"
	"strings"

	"github.com/peak/s5cmd/v2/storage/url"
	"github.com/urfave/cli/v2"
)

func commandFromContext(c *cli.Context) string {
	cmd := c.Command.FullName()

	for _, f := range c.Command.Flags {
		flagname := f.Names()[0]
		for _, flagvalue := range contextValue(c, flagname) {
			cmd = fmt.Sprintf("%s --%s=%v", cmd, flagname, flagvalue)
		}
	}

	if c.Args().Len() > 0 {
		cmd = fmt.Sprintf("%v %v", cmd, strings.Join(c.Args().Slice(), " "))
	}

	return cmd
}

// contextValue traverses context and its ancestor contexts to find
// the flag value and returns string slice.
func contextValue(c *cli.Context, flagname string) []string {
	for _, c := range c.Lineage() {
		if !c.IsSet(flagname) {
			continue
		}

		val := c.Value(flagname)
		switch val.(type) {
		case cli.StringSlice:
			return c.StringSlice(flagname)
		case cli.Int64Slice, cli.IntSlice:
			values := c.Int64Slice(flagname)
			var result []string
			for _, v := range values {
				result = append(result, strconv.FormatInt(v, 10))
			}
			return result
		case string:
			return []string{c.String(flagname)}
		case bool:
			return []string{strconv.FormatBool(c.Bool(flagname))}
		case int, int64:
			return []string{strconv.FormatInt(c.Int64(flagname), 10)}
		default:
			return []string{fmt.Sprintf("%v", val)}
		}
	}

	return nil
}

// generateCommand generates command string from given context, app command, default flags and urls.
func generateCommand(c *cli.Context, cmd string, defaultFlags map[string]interface{}, urls ...*url.URL) (string, error) {
	command := AppCommand(cmd)
	flagset := flag.NewFlagSet(command.Name, flag.ContinueOnError)

	var args []string
	for _, url := range urls {
		args = append(args, fmt.Sprintf("%q", url.String()))
	}

	flags := []string{}
	for flagname, flagvalue := range defaultFlags {
		flags = append(flags, fmt.Sprintf("--%s='%v'", flagname, flagvalue))
	}

	isDefaultFlag := func(flagname string) bool {
		_, ok := defaultFlags[flagname]
		return ok
	}

	for _, f := range command.Flags {
		flagname := f.Names()[0]
		if isDefaultFlag(flagname) || !c.IsSet(flagname) {
			continue
		}

		for _, flagvalue := range contextValue(c, flagname) {
			flags = append(flags, fmt.Sprintf("--%s='%s'", flagname, flagvalue))
		}
	}

	sort.Strings(flags)
	flags = append(flags, args...)
	flags = append([]string{command.Name}, flags...)

	err := flagset.Parse(flags)
	if err != nil {
		return "", err
	}

	cmdCtx := cli.NewContext(c.App, flagset, c)
	return strings.TrimSpace(commandFromContext(cmdCtx)), nil
}


text:
// Package chezmoiassert implements testing assertions not implemented by
// github.com/alecthomas/assert/v2.
package chezmoiassert

import (
	"fmt"
	"testing"

	"github.com/alecthomas/assert/v2"
)

func PanicsWithError(tb testing.TB, expected error, fn func(), msgAndArgs ...interface{}) {
	tb.Helper()
	defer func() {
		if value, ok := recover().(error); ok {
			assert.Equal(tb, expected, value, msgAndArgs...)
		} else {
			msg := formatMsgAndArgs("Expected function to panic with error", msgAndArgs...)
			tb.Fatal(msg)
		}
	}()
	fn()
}

func PanicsWithErrorString(tb testing.TB, errString string, fn func(), msgAndArgs ...interface{}) {
	tb.Helper()
	defer func() {
		if value, ok := recover().(error); ok {
			assert.EqualError(tb, value, errString, msgAndArgs...)
		} else {
			msg := formatMsgAndArgs("Expected function to panic with error string", msgAndArgs...)
			tb.Fatal(msg)
		}
	}()
	fn()
}

func formatMsgAndArgs(dflt string, msgAndArgs ...interface{}) string {
	if len(msgAndArgs) == 0 {
		return dflt
	}
	return fmt.Sprintf(msgAndArgs[0].(string), msgAndArgs[1:]...) //nolint:forcetypeassert
}

repository: twpayne/chezmoi

repo_name: twpayne/chezmoi


text:
// Copyright (c) 2016 OpenM++
// This code is licensed under the MIT license (see LICENSE.txt for details)

package main

import (
	"errors"
	"os"

	"github.com/openmpp/go/ompp/omppLog"
)

// isDirExist true if path exists and it is directory, return error if path is not a directory or not accessible
func isDirExist(dirPath string) (bool, error) {
	fi, err := os.Stat(dirPath)
	if err != nil {
		if os.IsNotExist(err) {
			return false, nil
		}
		return false, errors.New("Error: unable to access directory: " + dirPath + " : " + err.Error())
	}
	if !fi.IsDir() {
		return false, errors.New("Error: directory expected: " + dirPath)
	}
	return true, nil
}

// Delete file and log path if isLog is true, return false on delete error.
func dirDeleteAndLog(path string) bool {

	isExist, err := isDirExist(path)
	if err != nil {
		return false // error: path not accessible or it is not a directory
	}
	if !isExist {
		return true // OK: nothing to delete
	}

	omppLog.Log("Delete: ", path)

	if e := os.RemoveAll(path); e != nil && !os.IsNotExist(e) {
		omppLog.Log(e)
		return false // error: delete failed
	}
	return true // OK: deleted successfully
}

repository: openmpp/go

repo_name: openmpp/go


text:
package helpers

import (
	"fmt"
	"strings"

	"github.com/open-cluster-management/hub-of-hubs-status-transport-bridge/pkg/bundle"
)

// GetBundleType returns the concrete type of a bundle.
func GetBundleType(bundle bundle.Bundle) string {
	array := strings.Split(fmt.Sprintf("%T", bundle), ".")
	return array[len(array)-1]
}

branch_name: refs/heads/main


text:
@InProceedings{johnson16,
  title = {Supervised and Semi-Supervised Text Categorization using LSTM for Region Embeddings},
  author = {Rie Johnson and Tong Zhang},
  pages = {526-534},
  abstract = {One-hot CNN (convolutional neural network) has been shown to be effective for text categorization (Johnson \& Zhang, 2015). We view it as a special case of a general framework which jointly trains a linear model with a non-linear feature generator consisting of `text region embedding + pooling'. Under this framework, we explore a more sophisticated region embedding method using Long Short-Term Memory (LSTM). LSTM can embed text regions of variable (and possibly large) sizes, whereas the region size needs to be fixed in a CNN. We seek effective and efficient use of LSTM for this purpose in the supervised and semi-supervised settings. The best results were obtained by combining region embeddings in the form of LSTM and convolution layers trained on unlabeled data. The results indicate that on this task, embeddings of text regions, which can convey complex concepts, are more useful than embeddings of single words in isolation. We report performances exceeding the previous best results on four benchmark datasets.},
}

repository: mreid/papersite

repo_name: mreid/papersite

gha_language: TeX


text:
#
# Copyright (c) 2021, NXP
#
# SPDX-License-Identifier: Apache-2.0
#

if(CONFIG_SOC_MIMXRT1176_CM7 OR CONFIG_SECOND_CORE_MCUX)
board_runner_args(pyocd "--target=mimxrt1170_cm7")
board_runner_args(jlink "--device=MIMXRT1176xxxA_M7" "--reset-after-load")
elseif(CONFIG_SOC_MIMXRT1176_CM4)
board_runner_args(pyocd "--target=mimxrt1170_cm4")
# Note: Please use JLINK above V7.50 (Only support run cm4 image when debugging due to default boot core on board is cm7 core)
board_runner_args(jlink "--device=MIMXRT1176xxxA_M4")
endif()

include(${ZEPHYR_BASE}/boards/common/jlink.board.cmake)
include(${ZEPHYR_BASE}/boards/common/pyocd.board.cmake)

repository: intel/zephyr

repo_name: intel/zephyr

gha_language: C

extension: cmake


text:
package diskserver

import (
	"encoding/json"
	"net/http"
	"os"
	"time"

	"github.com/golang/glog"
)

const (
	StartLogTemplate         = "begin: host=[%s] remoteRealIP=[%s] method=[%s] url=[%s] start_time=[%s] form_data=[%s] \n"
	EndLogTemplate           = "end: host=[%s] remoteRealIP=[%s] method=[%s] url=[%s] status=[%d] end_time=[%s] process_time=[%d] form_data=[%s] header=[%s] errmsg=[%v] \n"
	TimeFormat               = "2006-01-02 15:04:05"
	defaultMaxMemory   int64 = 32 << 20 // 32 MB
	RespBodyTypeJson         = "json"
	RespBodyTypeString       = "string"
)

type Context struct {
	RemoteRealIP   string
	Host           string
	Start          time.Time
	ProcessTime    int64
	FormValues     string
	Request        *http.Request
	RespHttpStatus int
	Err            error
	RespBodyType   string
	RespBody       string
	RespBodyJson   interface{}
}

// get hostname
func hostName() string {
	host, err := os.Hostname()
	if err != nil {
		return "unknown"
	}
	return host
}

func NewContext(r *http.Request) *Context {
	var realIP string
	if len(r.Header[HeaderXRealIP]) > 0 {
		realIP = r.Header[HeaderXRealIP][0]
	}
	if realIP == "" {
		realIP = r.Header.Get(HeaderXRealIP)
	}

	r.ParseMultipartForm(defaultMaxMemory)
	data, _ := json.Marshal(r.Form)

	ctx := &Context{
		RemoteRealIP:   realIP,
		Host:           hostName(),
		Start:          time.Now(),
		Request:        r,
		FormValues:     string(data),
		RespBodyType:   RespBodyTypeJson,
		RespHttpStatus: http.StatusOK,
	}

	glog.V(0).Infof(StartLogTemplate, ctx.Host, ctx.RemoteRealIP, ctx.Request.Method, ctx.Request.RequestURI, ctx.Start.Format(TimeFormat), ctx.FormValues)
	return ctx
}

func Summary(w http.ResponseWriter, ctx *Context) {
	Logger(ctx)
}

// service log
func Logger(ctx *Context) {
	ctx.ProcessTime = time.Since(ctx.Start).Nanoseconds() / time.Millisecond.Nanoseconds()
	// print request header
	data, _ := json.Marshal(ctx.Request.Header)

	glog.V(0).Infof(EndLogTemplate, ctx.Host, ctx.RemoteRealIP, ctx.Request.Method, ctx.Request.RequestURI, ctx.RespHttpStatus, time.Now().Format(TimeFormat),
		ctx.ProcessTime, ctx.FormValues, string(data), ctx.Err)
}

repository: nilebit/bitstore

repo_name: nilebit/bitstore


text:
// +build all unit

package gocql

import (
	"testing"
)

// fakeNode is used as a simple structure to test the RoundRobin API
type fakeNode struct {
	conn   *Conn
	closed bool
}

// Pick is needed to satisfy the Node interface
func (n *fakeNode) Pick(qry *Query) *Conn {
	if n.conn == nil {
		n.conn = &Conn{}
	}
	return n.conn
}

//Close is needed to satisfy the Node interface
func (n *fakeNode) Close() {
	n.closed = true
}

//TestRoundRobinAPI tests the exported methods of the RoundRobin struct
//to make sure the API behaves accordingly.
func TestRoundRobinAPI(t *testing.T) {
	node := &fakeNode{}
	rr := NewRoundRobin()
	rr.AddNode(node)

	if rr.Size() != 1 {
		t.Fatalf("expected size to be 1, got %v", rr.Size())
	}

	if c := rr.Pick(nil); c != node.conn {
		t.Fatalf("expected conn %v, got %v", node.conn, c)
	}

	rr.Close()
	if rr.pool != nil {
		t.Fatalf("expected rr.pool to be nil, got %v", rr.pool)
	}

	if !node.closed {
		t.Fatal("expected node.closed to be true, got false")
	}
}

repository: f/koding

repo_name: f/koding

gha_language: CoffeeScript