code stringlengths 5 1.01M | repo_name stringlengths 5 84 | path stringlengths 4 311 | language stringclasses 30
values | license stringclasses 15
values | size int64 5 1.01M | input_ids listlengths 502 502 | token_type_ids listlengths 502 502 | attention_mask listlengths 502 502 | labels listlengths 502 502 |
|---|---|---|---|---|---|---|---|---|---|
package com.stech.meetat.service;
public interface SchedulerService {
}
| vijayvelpula/MeetAt | src/main/java/com/stech/meetat/service/SchedulerService.java | Java | unlicense | 74 | [
30522,
7427,
4012,
1012,
26261,
2818,
1012,
3113,
4017,
1012,
2326,
1025,
2270,
8278,
6134,
22573,
2099,
7903,
2063,
1063,
1065,
102,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
package com.swfarm.biz.chain.web;
import java.io.OutputStream;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.commons.lang.ArrayUtils;
import org.apache.commons.lang.StringUtils;
import org.apache.poi.hssf.usermodel.HSSFCell;
import org.apache.poi.hssf.usermodel.HSSFRow;
import org.apache.poi.hssf.usermodel.HSSFSheet;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.ss.usermodel.CellStyle;
import org.apache.poi.ss.usermodel.DataFormat;
import org.apache.poi.ss.usermodel.Font;
import org.apache.poi.ss.usermodel.IndexedColors;
import org.apache.poi.ss.usermodel.PrintSetup;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.AbstractController;
import com.swfarm.biz.chain.bo.CustomerOrder;
import com.swfarm.biz.chain.bo.SaleChannelAccount;
import com.swfarm.biz.chain.srv.ChainService;
import com.swfarm.biz.warehouse.bo.AllocationProductVoucher;
import com.swfarm.biz.warehouse.bo.AllocationProductVoucherList;
import com.swfarm.biz.warehouse.srv.WarehouseService;
import com.swfarm.pub.utils.ImageUtils;
public class DownloadSmtTrackingListController extends AbstractController {
private static final String[] titles = { "订单编号", "发货单号", "平台单号", "货运单号",
"店铺编号" };
private static final double MAGIC_FACTOR = 1.112877583;
private WarehouseService warehouseService;
private ChainService chainService;
public void setWarehouseService(WarehouseService warehouseService) {
this.warehouseService = warehouseService;
}
public void setChainService(ChainService chainService) {
this.chainService = chainService;
}
@Override
protected ModelAndView handleRequestInternal(HttpServletRequest req,
HttpServletResponse res) throws Exception {
Long apvlId = new Long(req.getParameter("apvl"));
AllocationProductVoucherList allocationProductVoucherList = this.warehouseService
.findAllocationProductVoucherList(apvlId);
HSSFWorkbook wb = new HSSFWorkbook();
Map<String, CellStyle> styles = createStyles(wb);
HSSFSheet sheet = wb.createSheet("客户订单");
sheet.setFitToPage(true);
sheet.setHorizontallyCenter(true);
PrintSetup printSetup = sheet.getPrintSetup();
printSetup.setLandscape(false);
sheet.setAutobreaks(true);
printSetup.setFitHeight((short) 1);
printSetup.setFitWidth((short) 1);
HSSFRow headerRow = sheet.createRow(0);
headerRow.setHeightInPoints(12.75f);
for (int i = 0; i < titles.length; i++) {
HSSFCell cell = headerRow.createCell(i);
cell.setCellValue(titles[i]);
cell.setCellStyle(styles.get("header"));
}
HSSFRow row = null;
HSSFCell cell = null;
for (int i = 0; i < 4; i++) {
sheet.setColumnWidth(i, (int) (15 * 256 * MAGIC_FACTOR));
}
int rowCounter = 1;
for (Iterator iter = allocationProductVoucherList
.getAllocationProductVoucherList().iterator(); iter.hasNext();) {
AllocationProductVoucher apv = (AllocationProductVoucher) iter
.next();
CustomerOrder customerOrder = apv.getCustomerOrder();
String sfmCode = apv.getShippingForwarderMethod();
String[] ywPySfmCodes = new String[] { "YUB", "YWCNPY", "BJGH", "BKGH" };
row = sheet.createRow(rowCounter);
int cellCounter = 0;
// A
cell = row.createCell(cellCounter++);
cell.setCellValue(customerOrder.getCustomerOrderNo());
cell.setCellStyle(styles.get("cell_normal"));
// B
cell = row.createCell(cellCounter++);
cell.setCellValue(apv.getAllocationProductVoucherNo());
cell.setCellStyle(styles.get("cell_normal"));
// C
cell = row.createCell(cellCounter++);
cell.setCellValue(customerOrder.getSaleChannelOrderId());
cell.setCellStyle(styles.get("cell_normal"));
// D
cell = row.createCell(cellCounter++);
if (ArrayUtils.contains(ywPySfmCodes, sfmCode)) {
cell.setCellValue(apv.getRefShippingOrderNo());
} else {
cell.setCellValue(apv.getShippingOrderNo());
}
cell.setCellStyle(styles.get("cell_normal"));
// E
cell = row.createCell(cellCounter++);
String accountNumber = customerOrder.getAccountNumber();
if (StringUtils.isNotEmpty(accountNumber)) {
SaleChannelAccount saleChannelAccount = this.chainService
.findSaleChannelAccountByAccountNumber(accountNumber);
cell.setCellValue(saleChannelAccount.getAccountNumberSeq());
}
cell.setCellStyle(styles.get("cell_normal"));
rowCounter++;
}
res.setContentType("application/ms-excel");
String fileName = "客户订单.xls";
res.setHeader("Content-Disposition", "attachment; filename="
+ java.net.URLEncoder.encode(fileName, "UTF-8"));
OutputStream out = res.getOutputStream();
wb.write(out);
return null;
}
private static Map<String, CellStyle> createStyles(HSSFWorkbook wb) {
Map<String, CellStyle> styles = new HashMap<String, CellStyle>();
DataFormat df = wb.createDataFormat();
CellStyle style;
Font headerFont = wb.createFont();
headerFont.setBoldweight(Font.BOLDWEIGHT_BOLD);
headerFont.setFontHeightInPoints((short) 10);
style = createBorderedStyle(wb);
style.setAlignment(CellStyle.ALIGN_CENTER);
style.setVerticalAlignment(CellStyle.VERTICAL_CENTER);
style.setFillForegroundColor(IndexedColors.GREY_25_PERCENT.getIndex());
style.setFillPattern(CellStyle.SOLID_FOREGROUND);
style.setFont(headerFont);
styles.put("header", style);
style = createBorderedStyle(wb);
style.setAlignment(CellStyle.ALIGN_CENTER);
style.setVerticalAlignment(CellStyle.VERTICAL_CENTER);
style.setFillForegroundColor(IndexedColors.GREY_25_PERCENT.getIndex());
style.setFillPattern(CellStyle.SOLID_FOREGROUND);
style.setFont(headerFont);
style.setDataFormat(df.getFormat("d-mmm"));
styles.put("header_date", style);
Font font1 = wb.createFont();
font1.setBoldweight(Font.BOLDWEIGHT_BOLD);
font1.setFontHeightInPoints((short) 10);
style = createBorderedStyle(wb);
style.setAlignment(CellStyle.ALIGN_LEFT);
style.setFont(font1);
styles.put("cell_b", style);
style = createBorderedStyle(wb);
style.setAlignment(CellStyle.ALIGN_CENTER);
style.setFont(font1);
styles.put("cell_b_centered", style);
style = createBorderedStyle(wb);
style.setAlignment(CellStyle.ALIGN_RIGHT);
style.setFont(font1);
style.setDataFormat(df.getFormat("d-mmm"));
styles.put("cell_b_date", style);
style = createBorderedStyle(wb);
style.setAlignment(CellStyle.ALIGN_RIGHT);
style.setFont(font1);
style.setFillForegroundColor(IndexedColors.GREY_25_PERCENT.getIndex());
style.setFillPattern(CellStyle.SOLID_FOREGROUND);
style.setDataFormat(df.getFormat("d-mmm"));
styles.put("cell_g", style);
Font font2 = wb.createFont();
font2.setColor(IndexedColors.BLUE.getIndex());
font2.setBoldweight(Font.BOLDWEIGHT_BOLD);
style = createBorderedStyle(wb);
style.setAlignment(CellStyle.ALIGN_LEFT);
style.setFont(font2);
styles.put("cell_bb", style);
style = createBorderedStyle(wb);
style.setAlignment(CellStyle.ALIGN_RIGHT);
style.setFont(font1);
style.setFillForegroundColor(IndexedColors.GREY_25_PERCENT.getIndex());
style.setFillPattern(CellStyle.SOLID_FOREGROUND);
style.setDataFormat(df.getFormat("d-mmm"));
styles.put("cell_bg", style);
Font font3 = wb.createFont();
font3.setFontHeightInPoints((short) 10);
font3.setColor(IndexedColors.DARK_BLUE.getIndex());
font3.setBoldweight(Font.BOLDWEIGHT_BOLD);
style = createBorderedStyle(wb);
style.setAlignment(CellStyle.ALIGN_LEFT);
style.setFont(font3);
style.setWrapText(true);
styles.put("cell_h", style);
Font normalFont = wb.createFont();
normalFont.setFontHeightInPoints((short) 10);
style = createBorderedStyle(wb);
style.setAlignment(CellStyle.ALIGN_LEFT);
style.setWrapText(true);
style.setFont(normalFont);
styles.put("cell_normal", style);
style = createBorderedStyle(wb);
style.setAlignment(CellStyle.ALIGN_CENTER);
style.setWrapText(true);
styles.put("cell_normal_centered", style);
style = createBorderedStyle(wb);
style.setAlignment(CellStyle.ALIGN_RIGHT);
style.setWrapText(true);
style.setDataFormat(df.getFormat("d-mmm"));
styles.put("cell_normal_date", style);
style = createBorderedStyle(wb);
style.setAlignment(CellStyle.ALIGN_LEFT);
style.setIndention((short) 1);
style.setWrapText(true);
styles.put("cell_indented", style);
style = createBorderedStyle(wb);
style.setFillForegroundColor(IndexedColors.BLUE.getIndex());
style.setFillPattern(CellStyle.SOLID_FOREGROUND);
styles.put("cell_blue", style);
return styles;
}
private static CellStyle createBorderedStyle(HSSFWorkbook wb) {
CellStyle style = wb.createCellStyle();
style.setBorderRight(CellStyle.BORDER_THIN);
style.setRightBorderColor(IndexedColors.BLACK.getIndex());
style.setBorderBottom(CellStyle.BORDER_THIN);
style.setBottomBorderColor(IndexedColors.BLACK.getIndex());
style.setBorderLeft(CellStyle.BORDER_THIN);
style.setLeftBorderColor(IndexedColors.BLACK.getIndex());
style.setBorderTop(CellStyle.BORDER_THIN);
style.setTopBorderColor(IndexedColors.BLACK.getIndex());
return style;
}
private static byte[] getImage(String url) {
return ImageUtils.generateImage(url);
}
}
| zhangqiang110/my4j | pms/src/main/java/com/swfarm/biz/chain/web/DownloadSmtTrackingListController.java | Java | mit | 9,538 | [
30522,
7427,
4012,
1012,
25430,
14971,
2213,
1012,
12170,
2480,
1012,
4677,
1012,
4773,
1025,
12324,
9262,
1012,
22834,
1012,
27852,
25379,
1025,
12324,
9262,
1012,
21183,
4014,
1012,
23325,
2863,
2361,
1025,
12324,
9262,
1012,
21183,
4014,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
//
//////////////////////////////////////////////////////////////////////////////
//
// Copyright 2018 Autodesk, Inc. All rights reserved.
//
// Use of this software is subject to the terms of the Autodesk license
// agreement provided at the time of installation or download, or which
// otherwise accompanies this software in either electronic or hard copy form.
//
//////////////////////////////////////////////////////////////////////////////
//
//
#ifndef __AXPNT2D_H_
#define __AXPNT2D_H_
#include "gept2dar.h"
#include "gepnt2d.h"
#include "gevec2d.h"
#pragma pack (push, 8)
#ifndef AXAUTOEXP
#ifdef AXAUTO_DLL
#define AXAUTOEXP __declspec(dllexport)
#else
#define AXAUTOEXP __declspec(dllimport)
#endif
#endif
#pragma warning(disable : 4290)
class AXAUTOEXP AcAxPoint2d : public AcGePoint2d
{
public:
// constructors
AcAxPoint2d();
AcAxPoint2d(double x, double y);
AcAxPoint2d(const AcGePoint2d& pt);
AcAxPoint2d(const AcGeVector2d& pt);
AcAxPoint2d(const VARIANT* var) throw(HRESULT);
AcAxPoint2d(const VARIANT& var) throw(HRESULT);
AcAxPoint2d(const SAFEARRAY* safeArrayPt) throw(HRESULT);
// equal operators
AcAxPoint2d& operator=(const AcGePoint2d& pt);
AcAxPoint2d& operator=(const AcGeVector2d& pt);
AcAxPoint2d& operator=(const VARIANT* var) throw(HRESULT);
AcAxPoint2d& operator=(const VARIANT& var) throw(HRESULT);
AcAxPoint2d& operator=(const SAFEARRAY* safeArrayPt) throw(HRESULT);
// type requests
VARIANT* asVariantPtr() const throw(HRESULT);
SAFEARRAY* asSafeArrayPtr() const throw(HRESULT);
VARIANT& setVariant(VARIANT& var) const throw(HRESULT);
VARIANT* setVariant(VARIANT* var) const throw(HRESULT);
// utilities
private:
AcAxPoint2d& fromSafeArray(const SAFEARRAY* safeArrayPt) throw(HRESULT);
};
#pragma warning(disable : 4275)
class AXAUTOEXP AcAxPoint2dArray : public AcGePoint2dArray
{
public:
// equal operators
AcAxPoint2dArray& append(const AcGePoint2d& pt);
AcAxPoint2dArray& append(const VARIANT* var) throw(HRESULT);
AcAxPoint2dArray& append(const VARIANT& var) throw(HRESULT);
AcAxPoint2dArray& append(const SAFEARRAY* safeArrayPt) throw(HRESULT);
// type requests
SAFEARRAY* asSafeArrayPtr() const throw(HRESULT);
VARIANT& setVariant(VARIANT& var) const throw(HRESULT);
VARIANT* setVariant(VARIANT* var) const throw(HRESULT);
// utilities
private:
AcAxPoint2dArray& fromSafeArray(const SAFEARRAY* safeArrayPt) throw(HRESULT);
};
#pragma pack (pop)
#endif
| satya-das/cppparser | test/e2e/test_input/ObjectArxHeaders/axpnt2d.h | C | mit | 2,559 | [
30522,
1013,
1013,
1013,
1013,
1013,
1013,
1013,
1013,
1013,
1013,
1013,
1013,
1013,
1013,
1013,
1013,
1013,
1013,
1013,
1013,
1013,
1013,
1013,
1013,
1013,
1013,
1013,
1013,
1013,
1013,
1013,
1013,
1013,
1013,
1013,
1013,
1013,
1013,
101... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
namespace Engine.Contracts
{
public interface IAct
{
/// <summary>
/// Makes an act (or try) and returns how much time it takes
/// </summary>
/// <param name="scene">Scene on which act plays</param>
/// <returns>Time passed</returns>
ActResult Do(IScene scene);
string Name { get; set; }
bool CanDo(IActor actor, IScene scene);
}
public class ActResult
{
public int TimePassed;
public string Message;
}
}
| sheix/GameEngine | Engine/Contracts/IAct.cs | C# | mit | 482 | [
30522,
3415,
15327,
3194,
1012,
8311,
1063,
2270,
8278,
24264,
6593,
1063,
1013,
1013,
1013,
1026,
12654,
1028,
1013,
1013,
1013,
3084,
2019,
2552,
1006,
2030,
3046,
1007,
1998,
5651,
2129,
2172,
2051,
2009,
3138,
1013,
1013,
1013,
1026,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
<?php
if(!function_exists ('ew_code')){
function ew_code($atts,$content = false){
extract(shortcode_atts(array(
),$atts));
//add_filter('the_content','ew_do_shortcode',1001);
return "<div class='border-code'><div class='background-code'><pre class='code'>".htmlspecialchars($content)."</pre></div></div>";
}
}
add_shortcode('code','ew_code');
?> | DiegoUX/recubre | wp-content/themes/recubre/framework/shortcodes/code.php | PHP | gpl-2.0 | 356 | [
30522,
1026,
1029,
25718,
2065,
1006,
999,
3853,
1035,
6526,
1006,
1005,
1041,
2860,
1035,
3642,
1005,
1007,
1007,
1063,
3853,
1041,
2860,
1035,
3642,
1006,
1002,
2012,
3215,
1010,
1002,
4180,
1027,
6270,
1007,
1063,
14817,
1006,
2460,
16... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
/*
* Copyright 2013 Steve Vickers
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* Created on: Jun 15, 2014
*/
package reactivemongo.extensions.dsl.criteria
import org.scalatest._
import org.scalatest.matchers._
import reactivemongo.bson._
/**
* The '''UntypedWhereSpec''' type verifies the behaviour expected of the
* `where` method in the [[reactivemongo.extensions.dsl.criteria.Untyped]]
* `type`.
*
* @author svickers
*
*/
class UntypedWhereSpec
extends FlatSpec
with Matchers {
/// Class Imports
import Untyped._
"An Untyped where" should "support 1 placeholder" in
{
val q = where {
_.a === 1
}
BSONDocument.pretty(q) shouldBe (
BSONDocument.pretty(
BSONDocument(
"a" -> BSONInteger(1)
)
)
);
}
it should "support 2 placeholders" in
{
val q = where {
_.a === 1 && _.b === 2
}
BSONDocument.pretty(q) shouldBe (
BSONDocument.pretty(
BSONDocument(
"$and" ->
BSONArray(
BSONDocument(
"a" -> BSONInteger(1)
),
BSONDocument(
"b" -> BSONInteger(2)
)
)
)
)
);
}
it should "support 3 placeholders" in
{
val q = where {
_.a === 1 && _.b === 2 && _.c === 3
}
BSONDocument.pretty(q) shouldBe (
BSONDocument.pretty(
BSONDocument(
"$and" ->
BSONArray(
BSONDocument(
"a" -> BSONInteger(1)
),
BSONDocument(
"b" -> BSONInteger(2)
),
BSONDocument(
"c" -> BSONInteger(3)
)
)
)
)
);
}
/// The library supports from 1 to 22 placeholders for the where method.
it should "support 22 placeholders" in
{
val q = where {
_.p === 0 &&
_.p === 0 &&
_.p === 0 &&
_.p === 0 &&
_.p === 0 &&
_.p === 0 &&
_.p === 0 &&
_.p === 0 &&
_.p === 0 &&
_.p === 0 &&
_.p === 0 &&
_.p === 0 &&
_.p === 0 &&
_.p === 0 &&
_.p === 0 &&
_.p === 0 &&
_.p === 0 &&
_.p === 0 &&
_.p === 0 &&
_.p === 0 &&
_.p === 0 &&
_.p === 0
}
BSONDocument.pretty(q) shouldBe (
BSONDocument.pretty(
BSONDocument(
"$and" ->
BSONArray(List.fill(22)(BSONDocument("p" -> BSONInteger(0))))
)
)
);
}
}
| ReactiveMongo/ReactiveMongo-Extensions | bson/src/test/scala/dsl/criteria/UntypedWhereSpec.scala | Scala | apache-2.0 | 3,275 | [
30522,
1013,
1008,
1008,
9385,
2286,
3889,
18571,
1008,
1008,
7000,
2104,
1996,
15895,
6105,
1010,
2544,
1016,
1012,
1014,
1006,
1996,
1000,
6105,
1000,
1007,
1025,
1008,
2017,
2089,
2025,
2224,
2023,
5371,
3272,
1999,
12646,
2007,
1996,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
/**!
* The MIT License
*
* Copyright (c) 2010-2012 Google, Inc. http://angularjs.org
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*
* angular-google-maps
* https://github.com/nlaplante/angular-google-maps
*
* @author Nicolas Laplante https://plus.google.com/108189012221374960701
*/
(function () {
"use strict";
/*
* Utility functions
*/
/**
* Check if 2 floating point numbers are equal
*
* @see http://stackoverflow.com/a/588014
*/
function floatEqual (f1, f2) {
return (Math.abs(f1 - f2) < 0.000001);
}
/*
* Create the model in a self-contained class where map-specific logic is
* done. This model will be used in the directive.
*/
var MapModel = (function () {
var _defaults = {
zoom: 8,
draggable: false,
container: null
};
/**
*
*/
function PrivateMapModel(opts) {
var _instance = null,
_markers = [], // caches the instances of google.maps.Marker
_handlers = [], // event handlers
_windows = [], // InfoWindow objects
o = angular.extend({}, _defaults, opts),
that = this,
currentInfoWindow = null;
this.center = opts.center;
this.zoom = o.zoom;
this.draggable = o.draggable;
this.dragging = false;
this.selector = o.container;
this.markers = [];
this.options = o.options;
this.draw = function () {
if (that.center == null) {
// TODO log error
return;
}
if (_instance == null) {
// Create a new map instance
_instance = new google.maps.Map(that.selector, angular.extend(that.options, {
center: that.center,
zoom: that.zoom,
draggable: that.draggable,
mapTypeId : google.maps.MapTypeId.ROADMAP
}));
google.maps.event.addListener(_instance, "dragstart",
function () {
that.dragging = true;
}
);
google.maps.event.addListener(_instance, "idle",
function () {
that.dragging = false;
}
);
google.maps.event.addListener(_instance, "drag",
function () {
that.dragging = true;
}
);
google.maps.event.addListener(_instance, "zoom_changed",
function () {
that.zoom = _instance.getZoom();
that.center = _instance.getCenter();
}
);
google.maps.event.addListener(_instance, "center_changed",
function () {
that.center = _instance.getCenter();
}
);
// Attach additional event listeners if needed
if (_handlers.length) {
angular.forEach(_handlers, function (h, i) {
google.maps.event.addListener(_instance,
h.on, h.handler);
});
}
}
else {
// Refresh the existing instance
google.maps.event.trigger(_instance, "resize");
var instanceCenter = _instance.getCenter();
if (!floatEqual(instanceCenter.lat(), that.center.lat())
|| !floatEqual(instanceCenter.lng(), that.center.lng())) {
_instance.setCenter(that.center);
}
if (_instance.getZoom() != that.zoom) {
_instance.setZoom(that.zoom);
}
}
};
this.fit = function () {
if (_instance && _markers.length) {
var bounds = new google.maps.LatLngBounds();
angular.forEach(_markers, function (m, i) {
bounds.extend(m.getPosition());
});
_instance.fitBounds(bounds);
}
};
this.on = function(event, handler) {
_handlers.push({
"on": event,
"handler": handler
});
};
this.addMarker = function (lat, lng, icon, infoWindowContent, label, url,
thumbnail) {
if (that.findMarker(lat, lng) != null) {
return;
}
var marker = new google.maps.Marker({
position: new google.maps.LatLng(lat, lng),
map: _instance,
icon: icon
});
if (label) {
}
if (url) {
}
if (infoWindowContent != null) {
var infoWindow = new google.maps.InfoWindow({
content: infoWindowContent
});
google.maps.event.addListener(marker, 'click', function() {
if (currentInfoWindow != null) {
currentInfoWindow.close();
}
infoWindow.open(_instance, marker);
currentInfoWindow = infoWindow;
});
}
// Cache marker
_markers.unshift(marker);
// Cache instance of our marker for scope purposes
that.markers.unshift({
"lat": lat,
"lng": lng,
"draggable": false,
"icon": icon,
"infoWindowContent": infoWindowContent,
"label": label,
"url": url,
"thumbnail": thumbnail
});
// Return marker instance
return marker;
};
this.findMarker = function (lat, lng) {
for (var i = 0; i < _markers.length; i++) {
var pos = _markers[i].getPosition();
if (floatEqual(pos.lat(), lat) && floatEqual(pos.lng(), lng)) {
return _markers[i];
}
}
return null;
};
this.findMarkerIndex = function (lat, lng) {
for (var i = 0; i < _markers.length; i++) {
var pos = _markers[i].getPosition();
if (floatEqual(pos.lat(), lat) && floatEqual(pos.lng(), lng)) {
return i;
}
}
return -1;
};
this.addInfoWindow = function (lat, lng, html) {
var win = new google.maps.InfoWindow({
content: html,
position: new google.maps.LatLng(lat, lng)
});
_windows.push(win);
return win;
};
this.hasMarker = function (lat, lng) {
return that.findMarker(lat, lng) !== null;
};
this.getMarkerInstances = function () {
return _markers;
};
this.removeMarkers = function (markerInstances) {
var s = this;
angular.forEach(markerInstances, function (v, i) {
var pos = v.getPosition(),
lat = pos.lat(),
lng = pos.lng(),
index = s.findMarkerIndex(lat, lng);
// Remove from local arrays
_markers.splice(index, 1);
s.markers.splice(index, 1);
// Remove from map
v.setMap(null);
});
};
}
// Done
return PrivateMapModel;
}());
// End model
// Start Angular directive
var googleMapsModule = angular.module("google-maps", []);
/**
* Map directive
*/
googleMapsModule.directive("googleMap", ["$log", "$timeout", "$filter", function ($log, $timeout,
$filter) {
var controller = function ($scope, $element) {
var _m = $scope.map;
self.addInfoWindow = function (lat, lng, content) {
_m.addInfoWindow(lat, lng, content);
};
};
controller.$inject = ['$scope', '$element'];
return {
restrict: "EC",
priority: 100,
transclude: true,
template: "<div class='angular-google-map' ng-transclude></div>",
replace: false,
scope: {
center: "=center", // required
markers: "=markers", // optional
latitude: "=latitude", // required
longitude: "=longitude", // required
zoom: "=zoom", // required
refresh: "&refresh", // optional
windows: "=windows" // optional"
},
controller: controller,
link: function (scope, element, attrs, ctrl) {
// Center property must be specified and provide lat &
// lng properties
if (!angular.isDefined(scope.center) ||
(!angular.isDefined(scope.center.lat) ||
!angular.isDefined(scope.center.lng))) {
$log.error("angular-google-maps: ould not find a valid center property");
return;
}
if (!angular.isDefined(scope.zoom)) {
$log.error("angular-google-maps: map zoom property not set");
return;
}
angular.element(element).addClass("angular-google-map");
// Parse options
var opts = {options: {}};
if (attrs.options) {
opts.options = angular.fromJson(attrs.options);
}
// Create our model
var _m = new MapModel(angular.extend(opts, {
container: element[0],
center: new google.maps.LatLng(scope.center.lat, scope.center.lng),
draggable: attrs.draggable == "true",
zoom: scope.zoom
}));
_m.on("drag", function () {
var c = _m.center;
$timeout(function () {
scope.$apply(function (s) {
scope.center.lat = c.lat();
scope.center.lng = c.lng();
});
});
});
_m.on("zoom_changed", function () {
if (scope.zoom != _m.zoom) {
$timeout(function () {
scope.$apply(function (s) {
scope.zoom = _m.zoom;
});
});
}
});
_m.on("center_changed", function () {
var c = _m.center;
$timeout(function () {
scope.$apply(function (s) {
if (!_m.dragging) {
scope.center.lat = c.lat();
scope.center.lng = c.lng();
}
});
});
});
if (attrs.markClick == "true") {
(function () {
var cm = null;
_m.on("click", function (e) {
if (cm == null) {
cm = {
latitude: e.latLng.lat(),
longitude: e.latLng.lng()
};
scope.markers.push(cm);
}
else {
cm.latitude = e.latLng.lat();
cm.longitude = e.latLng.lng();
}
$timeout(function () {
scope.latitude = cm.latitude;
scope.longitude = cm.longitude;
scope.$apply();
});
});
}());
}
// Put the map into the scope
scope.map = _m;
// Check if we need to refresh the map
if (angular.isUndefined(scope.refresh())) {
// No refresh property given; draw the map immediately
_m.draw();
}
else {
scope.$watch("refresh()", function (newValue, oldValue) {
if (newValue && !oldValue) {
_m.draw();
}
});
}
// Markers
scope.$watch("markers", function (newValue, oldValue) {
$timeout(function () {
angular.forEach(newValue, function (v, i) {
if (!_m.hasMarker(v.latitude, v.longitude)) {
_m.addMarker(v.latitude, v.longitude, v.icon, v.infoWindow);
}
});
// Clear orphaned markers
var orphaned = [];
angular.forEach(_m.getMarkerInstances(), function (v, i) {
// Check our scope if a marker with equal latitude and longitude.
// If not found, then that marker has been removed form the scope.
var pos = v.getPosition(),
lat = pos.lat(),
lng = pos.lng(),
found = false;
// Test against each marker in the scope
for (var si = 0; si < scope.markers.length; si++) {
var sm = scope.markers[si];
if (floatEqual(sm.latitude, lat) && floatEqual(sm.longitude, lng)) {
// Map marker is present in scope too, don't remove
found = true;
}
}
// Marker in map has not been found in scope. Remove.
if (!found) {
orphaned.push(v);
}
});
orphaned.length && _m.removeMarkers(orphaned);
// Fit map when there are more than one marker.
// This will change the map center coordinates
if (attrs.fit == "true" && newValue.length > 1) {
_m.fit();
}
});
}, true);
// Update map when center coordinates change
scope.$watch("center", function (newValue, oldValue) {
if (newValue === oldValue) {
return;
}
if (!_m.dragging) {
_m.center = new google.maps.LatLng(newValue.lat,
newValue.lng);
_m.draw();
}
}, true);
scope.$watch("zoom", function (newValue, oldValue) {
if (newValue === oldValue) {
return;
}
_m.zoom = newValue;
_m.draw();
});
}
};
}]);
}()); | HediMaiza/SmoothieParis | js/vendor/google-maps.js | JavaScript | gpl-2.0 | 15,335 | [
30522,
1013,
1008,
1008,
999,
1008,
1996,
10210,
6105,
1008,
1008,
9385,
1006,
1039,
1007,
2230,
1011,
2262,
8224,
1010,
4297,
1012,
8299,
1024,
1013,
1013,
16108,
22578,
1012,
8917,
1008,
1008,
6656,
2003,
2182,
3762,
4379,
1010,
2489,
1... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
#!/usr/bin/python
# -*- coding: utf-8 -*-
#
# Copyright (C) 2017 Google
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
# ----------------------------------------------------------------------------
#
# *** AUTO GENERATED CODE *** AUTO GENERATED CODE ***
#
# ----------------------------------------------------------------------------
#
# This file is automatically generated by Magic Modules and manual
# changes will be clobbered when the file is regenerated.
#
# Please read more about how to change this file at
# https://www.github.com/GoogleCloudPlatform/magic-modules
#
# ----------------------------------------------------------------------------
from __future__ import absolute_import, division, print_function
__metaclass__ = type
################################################################################
# Documentation
################################################################################
ANSIBLE_METADATA = {'metadata_version': '1.1', 'status': ["preview"], 'supported_by': 'community'}
DOCUMENTATION = '''
---
module: gcp_compute_backend_service
description:
- A Backend Service defines a group of virtual machines that will serve traffic for
load balancing. This resource is a global backend service, appropriate for external
load balancing or self-managed internal load balancing.
- For managed internal load balancing, use a regional backend service instead.
- Currently self-managed internal load balancing is only available in beta.
short_description: Creates a GCP BackendService
version_added: '2.6'
author: Google Inc. (@googlecloudplatform)
requirements:
- python >= 2.6
- requests >= 2.18.4
- google-auth >= 1.3.0
options:
state:
description:
- Whether the given object should exist in GCP
choices:
- present
- absent
default: present
type: str
affinity_cookie_ttl_sec:
description:
- Lifetime of cookies in seconds if session_affinity is GENERATED_COOKIE. If set
to 0, the cookie is non-persistent and lasts only until the end of the browser
session (or equivalent). The maximum allowed value for TTL is one day.
- When the load balancing scheme is INTERNAL, this field is not used.
required: false
type: int
backends:
description:
- The set of backends that serve this BackendService.
required: false
type: list
suboptions:
balancing_mode:
description:
- Specifies the balancing mode for this backend.
- For global HTTP(S) or TCP/SSL load balancing, the default is UTILIZATION.
Valid values are UTILIZATION, RATE (for HTTP(S)) and CONNECTION (for TCP/SSL).
- 'Some valid choices include: "UTILIZATION", "RATE", "CONNECTION"'
required: false
default: UTILIZATION
type: str
capacity_scaler:
description:
- A multiplier applied to the group's maximum servicing capacity (based on
UTILIZATION, RATE or CONNECTION).
- Default value is 1, which means the group will serve up to 100% of its configured
capacity (depending on balancingMode). A setting of 0 means the group is
completely drained, offering 0% of its available Capacity. Valid range is
[0.0,1.0].
required: false
default: '1.0'
type: str
description:
description:
- An optional description of this resource.
- Provide this property when you create the resource.
required: false
type: str
group:
description:
- The fully-qualified URL of an Instance Group or Network Endpoint Group resource.
In case of instance group this defines the list of instances that serve
traffic. Member virtual machine instances from each instance group must
live in the same zone as the instance group itself. No two backends in a
backend service are allowed to use same Instance Group resource.
- For Network Endpoint Groups this defines list of endpoints. All endpoints
of Network Endpoint Group must be hosted on instances located in the same
zone as the Network Endpoint Group.
- Backend service can not contain mix of Instance Group and Network Endpoint
Group backends.
- Note that you must specify an Instance Group or Network Endpoint Group resource
using the fully-qualified URL, rather than a partial URL.
required: false
type: str
max_connections:
description:
- The max number of simultaneous connections for the group. Can be used with
either CONNECTION or UTILIZATION balancing modes.
- For CONNECTION mode, either maxConnections or one of maxConnectionsPerInstance
or maxConnectionsPerEndpoint, as appropriate for group type, must be set.
required: false
type: int
max_connections_per_instance:
description:
- The max number of simultaneous connections that a single backend instance
can handle. This is used to calculate the capacity of the group. Can be
used in either CONNECTION or UTILIZATION balancing modes.
- For CONNECTION mode, either maxConnections or maxConnectionsPerInstance
must be set.
required: false
type: int
max_connections_per_endpoint:
description:
- The max number of simultaneous connections that a single backend network
endpoint can handle. This is used to calculate the capacity of the group.
Can be used in either CONNECTION or UTILIZATION balancing modes.
- For CONNECTION mode, either maxConnections or maxConnectionsPerEndpoint
must be set.
required: false
type: int
version_added: '2.9'
max_rate:
description:
- The max requests per second (RPS) of the group.
- Can be used with either RATE or UTILIZATION balancing modes, but required
if RATE mode. For RATE mode, either maxRate or one of maxRatePerInstance
or maxRatePerEndpoint, as appropriate for group type, must be set.
required: false
type: int
max_rate_per_instance:
description:
- The max requests per second (RPS) that a single backend instance can handle.
This is used to calculate the capacity of the group. Can be used in either
balancing mode. For RATE mode, either maxRate or maxRatePerInstance must
be set.
required: false
type: str
max_rate_per_endpoint:
description:
- The max requests per second (RPS) that a single backend network endpoint
can handle. This is used to calculate the capacity of the group. Can be
used in either balancing mode. For RATE mode, either maxRate or maxRatePerEndpoint
must be set.
required: false
type: str
version_added: '2.9'
max_utilization:
description:
- Used when balancingMode is UTILIZATION. This ratio defines the CPU utilization
target for the group. The default is 0.8. Valid range is [0.0, 1.0].
required: false
default: '0.8'
type: str
cdn_policy:
description:
- Cloud CDN configuration for this BackendService.
required: false
type: dict
suboptions:
cache_key_policy:
description:
- The CacheKeyPolicy for this CdnPolicy.
required: false
type: dict
suboptions:
include_host:
description:
- If true requests to different hosts will be cached separately.
required: false
type: bool
include_protocol:
description:
- If true, http and https requests will be cached separately.
required: false
type: bool
include_query_string:
description:
- If true, include query string parameters in the cache key according
to query_string_whitelist and query_string_blacklist. If neither is
set, the entire query string will be included.
- If false, the query string will be excluded from the cache key entirely.
required: false
type: bool
query_string_blacklist:
description:
- Names of query string parameters to exclude in cache keys.
- All other parameters will be included. Either specify query_string_whitelist
or query_string_blacklist, not both.
- "'&' and '=' will be percent encoded and not treated as delimiters."
required: false
type: list
query_string_whitelist:
description:
- Names of query string parameters to include in cache keys.
- All other parameters will be excluded. Either specify query_string_whitelist
or query_string_blacklist, not both.
- "'&' and '=' will be percent encoded and not treated as delimiters."
required: false
type: list
signed_url_cache_max_age_sec:
description:
- Maximum number of seconds the response to a signed URL request will be considered
fresh, defaults to 1hr (3600s). After this time period, the response will
be revalidated before being served.
- 'When serving responses to signed URL requests, Cloud CDN will internally
behave as though all responses from this backend had a "Cache-Control: public,
max-age=[TTL]" header, regardless of any existing Cache-Control header.
The actual headers served in responses will not be altered.'
required: false
default: '3600'
type: int
version_added: '2.8'
connection_draining:
description:
- Settings for connection draining .
required: false
type: dict
suboptions:
draining_timeout_sec:
description:
- Time for which instance will be drained (not accept new connections, but
still work to finish started).
required: false
default: '300'
type: int
description:
description:
- An optional description of this resource.
required: false
type: str
enable_cdn:
description:
- If true, enable Cloud CDN for this BackendService.
required: false
type: bool
health_checks:
description:
- The set of URLs to the HttpHealthCheck or HttpsHealthCheck resource for health
checking this BackendService. Currently at most one health check can be specified,
and a health check is required.
- For internal load balancing, a URL to a HealthCheck resource must be specified
instead.
required: true
type: list
iap:
description:
- Settings for enabling Cloud Identity Aware Proxy.
required: false
type: dict
version_added: '2.7'
suboptions:
enabled:
description:
- Enables IAP.
required: false
type: bool
oauth2_client_id:
description:
- OAuth2 Client ID for IAP .
required: true
type: str
oauth2_client_secret:
description:
- OAuth2 Client Secret for IAP .
required: true
type: str
load_balancing_scheme:
description:
- Indicates whether the backend service will be used with internal or external
load balancing. A backend service created for one type of load balancing cannot
be used with the other. Must be `EXTERNAL` or `INTERNAL_SELF_MANAGED` for a
global backend service. Defaults to `EXTERNAL`.
- 'Some valid choices include: "EXTERNAL", "INTERNAL_SELF_MANAGED"'
required: false
default: EXTERNAL
type: str
version_added: '2.7'
name:
description:
- Name of the resource. Provided by the client when the resource is created. The
name must be 1-63 characters long, and comply with RFC1035. Specifically, the
name must be 1-63 characters long and match the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?`
which means the first character must be a lowercase letter, and all following
characters must be a dash, lowercase letter, or digit, except the last character,
which cannot be a dash.
required: true
type: str
port_name:
description:
- Name of backend port. The same name should appear in the instance groups referenced
by this service. Required when the load balancing scheme is EXTERNAL.
required: false
type: str
protocol:
description:
- The protocol this BackendService uses to communicate with backends.
- 'Possible values are HTTP, HTTPS, HTTP2, TCP, and SSL. The default is HTTP.
**NOTE**: HTTP2 is only valid for beta HTTP/2 load balancer types and may result
in errors if used with the GA API.'
- 'Some valid choices include: "HTTP", "HTTPS", "HTTP2", "TCP", "SSL"'
required: false
type: str
security_policy:
description:
- The security policy associated with this backend service.
required: false
type: str
version_added: '2.8'
session_affinity:
description:
- Type of session affinity to use. The default is NONE. Session affinity is not
applicable if the protocol is UDP.
- 'Some valid choices include: "NONE", "CLIENT_IP", "CLIENT_IP_PORT_PROTO", "CLIENT_IP_PROTO",
"GENERATED_COOKIE", "HEADER_FIELD", "HTTP_COOKIE"'
required: false
type: str
timeout_sec:
description:
- How many seconds to wait for the backend before considering it a failed request.
Default is 30 seconds. Valid range is [1, 86400].
required: false
type: int
aliases:
- timeout_seconds
project:
description:
- The Google Cloud Platform project to use.
type: str
auth_kind:
description:
- The type of credential used.
type: str
required: true
choices:
- application
- machineaccount
- serviceaccount
service_account_contents:
description:
- The contents of a Service Account JSON file, either in a dictionary or as a
JSON string that represents it.
type: jsonarg
service_account_file:
description:
- The path of a Service Account JSON file if serviceaccount is selected as type.
type: path
service_account_email:
description:
- An optional service account email address if machineaccount is selected and
the user does not wish to use the default email.
type: str
scopes:
description:
- Array of scopes to be used
type: list
env_type:
description:
- Specifies which Ansible environment you're running this module within.
- This should not be set unless you know what you're doing.
- This only alters the User Agent string for any API requests.
type: str
notes:
- 'API Reference: U(https://cloud.google.com/compute/docs/reference/v1/backendServices)'
- 'Official Documentation: U(https://cloud.google.com/compute/docs/load-balancing/http/backend-service)'
- for authentication, you can set service_account_file using the c(gcp_service_account_file)
env variable.
- for authentication, you can set service_account_contents using the c(GCP_SERVICE_ACCOUNT_CONTENTS)
env variable.
- For authentication, you can set service_account_email using the C(GCP_SERVICE_ACCOUNT_EMAIL)
env variable.
- For authentication, you can set auth_kind using the C(GCP_AUTH_KIND) env variable.
- For authentication, you can set scopes using the C(GCP_SCOPES) env variable.
- Environment variables values will only be used if the playbook values are not set.
- The I(service_account_email) and I(service_account_file) options are mutually exclusive.
'''
EXAMPLES = '''
- name: create a instance group
gcp_compute_instance_group:
name: instancegroup-backendservice
zone: us-central1-a
project: "{{ gcp_project }}"
auth_kind: "{{ gcp_cred_kind }}"
service_account_file: "{{ gcp_cred_file }}"
state: present
register: instancegroup
- name: create a HTTP health check
gcp_compute_http_health_check:
name: httphealthcheck-backendservice
healthy_threshold: 10
port: 8080
timeout_sec: 2
unhealthy_threshold: 5
project: "{{ gcp_project }}"
auth_kind: "{{ gcp_cred_kind }}"
service_account_file: "{{ gcp_cred_file }}"
state: present
register: healthcheck
- name: create a backend service
gcp_compute_backend_service:
name: test_object
backends:
- group: "{{ instancegroup.selfLink }}"
health_checks:
- "{{ healthcheck.selfLink }}"
enable_cdn: 'true'
project: test_project
auth_kind: serviceaccount
service_account_file: "/tmp/auth.pem"
state: present
'''
RETURN = '''
affinityCookieTtlSec:
description:
- Lifetime of cookies in seconds if session_affinity is GENERATED_COOKIE. If set
to 0, the cookie is non-persistent and lasts only until the end of the browser
session (or equivalent). The maximum allowed value for TTL is one day.
- When the load balancing scheme is INTERNAL, this field is not used.
returned: success
type: int
backends:
description:
- The set of backends that serve this BackendService.
returned: success
type: complex
contains:
balancingMode:
description:
- Specifies the balancing mode for this backend.
- For global HTTP(S) or TCP/SSL load balancing, the default is UTILIZATION.
Valid values are UTILIZATION, RATE (for HTTP(S)) and CONNECTION (for TCP/SSL).
returned: success
type: str
capacityScaler:
description:
- A multiplier applied to the group's maximum servicing capacity (based on UTILIZATION,
RATE or CONNECTION).
- Default value is 1, which means the group will serve up to 100% of its configured
capacity (depending on balancingMode). A setting of 0 means the group is completely
drained, offering 0% of its available Capacity. Valid range is [0.0,1.0].
returned: success
type: str
description:
description:
- An optional description of this resource.
- Provide this property when you create the resource.
returned: success
type: str
group:
description:
- The fully-qualified URL of an Instance Group or Network Endpoint Group resource.
In case of instance group this defines the list of instances that serve traffic.
Member virtual machine instances from each instance group must live in the
same zone as the instance group itself. No two backends in a backend service
are allowed to use same Instance Group resource.
- For Network Endpoint Groups this defines list of endpoints. All endpoints
of Network Endpoint Group must be hosted on instances located in the same
zone as the Network Endpoint Group.
- Backend service can not contain mix of Instance Group and Network Endpoint
Group backends.
- Note that you must specify an Instance Group or Network Endpoint Group resource
using the fully-qualified URL, rather than a partial URL.
returned: success
type: str
maxConnections:
description:
- The max number of simultaneous connections for the group. Can be used with
either CONNECTION or UTILIZATION balancing modes.
- For CONNECTION mode, either maxConnections or one of maxConnectionsPerInstance
or maxConnectionsPerEndpoint, as appropriate for group type, must be set.
returned: success
type: int
maxConnectionsPerInstance:
description:
- The max number of simultaneous connections that a single backend instance
can handle. This is used to calculate the capacity of the group. Can be used
in either CONNECTION or UTILIZATION balancing modes.
- For CONNECTION mode, either maxConnections or maxConnectionsPerInstance must
be set.
returned: success
type: int
maxConnectionsPerEndpoint:
description:
- The max number of simultaneous connections that a single backend network endpoint
can handle. This is used to calculate the capacity of the group. Can be used
in either CONNECTION or UTILIZATION balancing modes.
- For CONNECTION mode, either maxConnections or maxConnectionsPerEndpoint must
be set.
returned: success
type: int
maxRate:
description:
- The max requests per second (RPS) of the group.
- Can be used with either RATE or UTILIZATION balancing modes, but required
if RATE mode. For RATE mode, either maxRate or one of maxRatePerInstance or
maxRatePerEndpoint, as appropriate for group type, must be set.
returned: success
type: int
maxRatePerInstance:
description:
- The max requests per second (RPS) that a single backend instance can handle.
This is used to calculate the capacity of the group. Can be used in either
balancing mode. For RATE mode, either maxRate or maxRatePerInstance must be
set.
returned: success
type: str
maxRatePerEndpoint:
description:
- The max requests per second (RPS) that a single backend network endpoint can
handle. This is used to calculate the capacity of the group. Can be used in
either balancing mode. For RATE mode, either maxRate or maxRatePerEndpoint
must be set.
returned: success
type: str
maxUtilization:
description:
- Used when balancingMode is UTILIZATION. This ratio defines the CPU utilization
target for the group. The default is 0.8. Valid range is [0.0, 1.0].
returned: success
type: str
cdnPolicy:
description:
- Cloud CDN configuration for this BackendService.
returned: success
type: complex
contains:
cacheKeyPolicy:
description:
- The CacheKeyPolicy for this CdnPolicy.
returned: success
type: complex
contains:
includeHost:
description:
- If true requests to different hosts will be cached separately.
returned: success
type: bool
includeProtocol:
description:
- If true, http and https requests will be cached separately.
returned: success
type: bool
includeQueryString:
description:
- If true, include query string parameters in the cache key according to
query_string_whitelist and query_string_blacklist. If neither is set,
the entire query string will be included.
- If false, the query string will be excluded from the cache key entirely.
returned: success
type: bool
queryStringBlacklist:
description:
- Names of query string parameters to exclude in cache keys.
- All other parameters will be included. Either specify query_string_whitelist
or query_string_blacklist, not both.
- "'&' and '=' will be percent encoded and not treated as delimiters."
returned: success
type: list
queryStringWhitelist:
description:
- Names of query string parameters to include in cache keys.
- All other parameters will be excluded. Either specify query_string_whitelist
or query_string_blacklist, not both.
- "'&' and '=' will be percent encoded and not treated as delimiters."
returned: success
type: list
signedUrlCacheMaxAgeSec:
description:
- Maximum number of seconds the response to a signed URL request will be considered
fresh, defaults to 1hr (3600s). After this time period, the response will
be revalidated before being served.
- 'When serving responses to signed URL requests, Cloud CDN will internally
behave as though all responses from this backend had a "Cache-Control: public,
max-age=[TTL]" header, regardless of any existing Cache-Control header. The
actual headers served in responses will not be altered.'
returned: success
type: int
connectionDraining:
description:
- Settings for connection draining .
returned: success
type: complex
contains:
drainingTimeoutSec:
description:
- Time for which instance will be drained (not accept new connections, but still
work to finish started).
returned: success
type: int
creationTimestamp:
description:
- Creation timestamp in RFC3339 text format.
returned: success
type: str
fingerprint:
description:
- Fingerprint of this resource. A hash of the contents stored in this object. This
field is used in optimistic locking.
returned: success
type: str
description:
description:
- An optional description of this resource.
returned: success
type: str
enableCDN:
description:
- If true, enable Cloud CDN for this BackendService.
returned: success
type: bool
healthChecks:
description:
- The set of URLs to the HttpHealthCheck or HttpsHealthCheck resource for health
checking this BackendService. Currently at most one health check can be specified,
and a health check is required.
- For internal load balancing, a URL to a HealthCheck resource must be specified
instead.
returned: success
type: list
id:
description:
- The unique identifier for the resource.
returned: success
type: int
iap:
description:
- Settings for enabling Cloud Identity Aware Proxy.
returned: success
type: complex
contains:
enabled:
description:
- Enables IAP.
returned: success
type: bool
oauth2ClientId:
description:
- OAuth2 Client ID for IAP .
returned: success
type: str
oauth2ClientSecret:
description:
- OAuth2 Client Secret for IAP .
returned: success
type: str
oauth2ClientSecretSha256:
description:
- OAuth2 Client Secret SHA-256 for IAP .
returned: success
type: str
loadBalancingScheme:
description:
- Indicates whether the backend service will be used with internal or external load
balancing. A backend service created for one type of load balancing cannot be
used with the other. Must be `EXTERNAL` or `INTERNAL_SELF_MANAGED` for a global
backend service. Defaults to `EXTERNAL`.
returned: success
type: str
name:
description:
- Name of the resource. Provided by the client when the resource is created. The
name must be 1-63 characters long, and comply with RFC1035. Specifically, the
name must be 1-63 characters long and match the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?`
which means the first character must be a lowercase letter, and all following
characters must be a dash, lowercase letter, or digit, except the last character,
which cannot be a dash.
returned: success
type: str
portName:
description:
- Name of backend port. The same name should appear in the instance groups referenced
by this service. Required when the load balancing scheme is EXTERNAL.
returned: success
type: str
protocol:
description:
- The protocol this BackendService uses to communicate with backends.
- 'Possible values are HTTP, HTTPS, HTTP2, TCP, and SSL. The default is HTTP. **NOTE**:
HTTP2 is only valid for beta HTTP/2 load balancer types and may result in errors
if used with the GA API.'
returned: success
type: str
securityPolicy:
description:
- The security policy associated with this backend service.
returned: success
type: str
sessionAffinity:
description:
- Type of session affinity to use. The default is NONE. Session affinity is not
applicable if the protocol is UDP.
returned: success
type: str
timeoutSec:
description:
- How many seconds to wait for the backend before considering it a failed request.
Default is 30 seconds. Valid range is [1, 86400].
returned: success
type: int
'''
################################################################################
# Imports
################################################################################
from ansible.module_utils.gcp_utils import navigate_hash, GcpSession, GcpModule, GcpRequest, remove_nones_from_dict, replace_resource_dict
import json
import time
################################################################################
# Main
################################################################################
def main():
"""Main function"""
module = GcpModule(
argument_spec=dict(
state=dict(default='present', choices=['present', 'absent'], type='str'),
affinity_cookie_ttl_sec=dict(type='int'),
backends=dict(
type='list',
elements='dict',
options=dict(
balancing_mode=dict(default='UTILIZATION', type='str'),
capacity_scaler=dict(default=1.0, type='str'),
description=dict(type='str'),
group=dict(type='str'),
max_connections=dict(type='int'),
max_connections_per_instance=dict(type='int'),
max_connections_per_endpoint=dict(type='int'),
max_rate=dict(type='int'),
max_rate_per_instance=dict(type='str'),
max_rate_per_endpoint=dict(type='str'),
max_utilization=dict(default=0.8, type='str'),
),
),
cdn_policy=dict(
type='dict',
options=dict(
cache_key_policy=dict(
type='dict',
options=dict(
include_host=dict(type='bool'),
include_protocol=dict(type='bool'),
include_query_string=dict(type='bool'),
query_string_blacklist=dict(type='list', elements='str'),
query_string_whitelist=dict(type='list', elements='str'),
),
),
signed_url_cache_max_age_sec=dict(default=3600, type='int'),
),
),
connection_draining=dict(type='dict', options=dict(draining_timeout_sec=dict(default=300, type='int'))),
description=dict(type='str'),
enable_cdn=dict(type='bool'),
health_checks=dict(required=True, type='list', elements='str'),
iap=dict(
type='dict',
options=dict(enabled=dict(type='bool'), oauth2_client_id=dict(required=True, type='str'), oauth2_client_secret=dict(required=True, type='str')),
),
load_balancing_scheme=dict(default='EXTERNAL', type='str'),
name=dict(required=True, type='str'),
port_name=dict(type='str'),
protocol=dict(type='str'),
security_policy=dict(type='str'),
session_affinity=dict(type='str'),
timeout_sec=dict(type='int', aliases=['timeout_seconds']),
)
)
if not module.params['scopes']:
module.params['scopes'] = ['https://www.googleapis.com/auth/compute']
state = module.params['state']
kind = 'compute#backendService'
fetch = fetch_resource(module, self_link(module), kind)
changed = False
if fetch:
if state == 'present':
if is_different(module, fetch):
update(module, self_link(module), kind, fetch)
fetch = fetch_resource(module, self_link(module), kind)
changed = True
else:
delete(module, self_link(module), kind)
fetch = {}
changed = True
else:
if state == 'present':
fetch = create(module, collection(module), kind)
changed = True
else:
fetch = {}
fetch.update({'changed': changed})
module.exit_json(**fetch)
def create(module, link, kind):
auth = GcpSession(module, 'compute')
return wait_for_operation(module, auth.post(link, resource_to_request(module)))
def update(module, link, kind, fetch):
update_fields(module, resource_to_request(module), response_to_hash(module, fetch))
auth = GcpSession(module, 'compute')
return wait_for_operation(module, auth.put(link, resource_to_request(module)))
def update_fields(module, request, response):
if response.get('securityPolicy') != request.get('securityPolicy'):
security_policy_update(module, request, response)
def security_policy_update(module, request, response):
auth = GcpSession(module, 'compute')
auth.post(
''.join(["https://www.googleapis.com/compute/v1/", "projects/{project}/global/backendServices/{name}/setSecurityPolicy"]).format(**module.params),
{u'securityPolicy': module.params.get('security_policy')},
)
def delete(module, link, kind):
auth = GcpSession(module, 'compute')
return wait_for_operation(module, auth.delete(link))
def resource_to_request(module):
request = {
u'kind': 'compute#backendService',
u'affinityCookieTtlSec': module.params.get('affinity_cookie_ttl_sec'),
u'backends': BackendServiceBackendsArray(module.params.get('backends', []), module).to_request(),
u'cdnPolicy': BackendServiceCdnpolicy(module.params.get('cdn_policy', {}), module).to_request(),
u'connectionDraining': BackendServiceConnectiondraining(module.params.get('connection_draining', {}), module).to_request(),
u'description': module.params.get('description'),
u'enableCDN': module.params.get('enable_cdn'),
u'healthChecks': module.params.get('health_checks'),
u'iap': BackendServiceIap(module.params.get('iap', {}), module).to_request(),
u'loadBalancingScheme': module.params.get('load_balancing_scheme'),
u'name': module.params.get('name'),
u'portName': module.params.get('port_name'),
u'protocol': module.params.get('protocol'),
u'securityPolicy': module.params.get('security_policy'),
u'sessionAffinity': module.params.get('session_affinity'),
u'timeoutSec': module.params.get('timeout_sec'),
}
return_vals = {}
for k, v in request.items():
if v or v is False:
return_vals[k] = v
return return_vals
def fetch_resource(module, link, kind, allow_not_found=True):
auth = GcpSession(module, 'compute')
return return_if_object(module, auth.get(link), kind, allow_not_found)
def self_link(module):
return "https://www.googleapis.com/compute/v1/projects/{project}/global/backendServices/{name}".format(**module.params)
def collection(module):
return "https://www.googleapis.com/compute/v1/projects/{project}/global/backendServices".format(**module.params)
def return_if_object(module, response, kind, allow_not_found=False):
# If not found, return nothing.
if allow_not_found and response.status_code == 404:
return None
# If no content, return nothing.
if response.status_code == 204:
return None
try:
module.raise_for_status(response)
result = response.json()
except getattr(json.decoder, 'JSONDecodeError', ValueError):
module.fail_json(msg="Invalid JSON response with error: %s" % response.text)
if navigate_hash(result, ['error', 'errors']):
module.fail_json(msg=navigate_hash(result, ['error', 'errors']))
return result
def is_different(module, response):
request = resource_to_request(module)
response = response_to_hash(module, response)
# Remove all output-only from response.
response_vals = {}
for k, v in response.items():
if k in request:
response_vals[k] = v
request_vals = {}
for k, v in request.items():
if k in response:
request_vals[k] = v
return GcpRequest(request_vals) != GcpRequest(response_vals)
# Remove unnecessary properties from the response.
# This is for doing comparisons with Ansible's current parameters.
def response_to_hash(module, response):
return {
u'affinityCookieTtlSec': response.get(u'affinityCookieTtlSec'),
u'backends': BackendServiceBackendsArray(response.get(u'backends', []), module).from_response(),
u'cdnPolicy': BackendServiceCdnpolicy(response.get(u'cdnPolicy', {}), module).from_response(),
u'connectionDraining': BackendServiceConnectiondraining(response.get(u'connectionDraining', {}), module).from_response(),
u'creationTimestamp': response.get(u'creationTimestamp'),
u'fingerprint': response.get(u'fingerprint'),
u'description': response.get(u'description'),
u'enableCDN': response.get(u'enableCDN'),
u'healthChecks': response.get(u'healthChecks'),
u'id': response.get(u'id'),
u'iap': BackendServiceIap(response.get(u'iap', {}), module).from_response(),
u'loadBalancingScheme': module.params.get('load_balancing_scheme'),
u'name': module.params.get('name'),
u'portName': response.get(u'portName'),
u'protocol': response.get(u'protocol'),
u'securityPolicy': response.get(u'securityPolicy'),
u'sessionAffinity': response.get(u'sessionAffinity'),
u'timeoutSec': response.get(u'timeoutSec'),
}
def async_op_url(module, extra_data=None):
if extra_data is None:
extra_data = {}
url = "https://www.googleapis.com/compute/v1/projects/{project}/global/operations/{op_id}"
combined = extra_data.copy()
combined.update(module.params)
return url.format(**combined)
def wait_for_operation(module, response):
op_result = return_if_object(module, response, 'compute#operation')
if op_result is None:
return {}
status = navigate_hash(op_result, ['status'])
wait_done = wait_for_completion(status, op_result, module)
return fetch_resource(module, navigate_hash(wait_done, ['targetLink']), 'compute#backendService')
def wait_for_completion(status, op_result, module):
op_id = navigate_hash(op_result, ['name'])
op_uri = async_op_url(module, {'op_id': op_id})
while status != 'DONE':
raise_if_errors(op_result, ['error', 'errors'], module)
time.sleep(1.0)
op_result = fetch_resource(module, op_uri, 'compute#operation', False)
status = navigate_hash(op_result, ['status'])
return op_result
def raise_if_errors(response, err_path, module):
errors = navigate_hash(response, err_path)
if errors is not None:
module.fail_json(msg=errors)
class BackendServiceBackendsArray(object):
def __init__(self, request, module):
self.module = module
if request:
self.request = request
else:
self.request = []
def to_request(self):
items = []
for item in self.request:
items.append(self._request_for_item(item))
return items
def from_response(self):
items = []
for item in self.request:
items.append(self._response_from_item(item))
return items
def _request_for_item(self, item):
return remove_nones_from_dict(
{
u'balancingMode': item.get('balancing_mode'),
u'capacityScaler': item.get('capacity_scaler'),
u'description': item.get('description'),
u'group': item.get('group'),
u'maxConnections': item.get('max_connections'),
u'maxConnectionsPerInstance': item.get('max_connections_per_instance'),
u'maxConnectionsPerEndpoint': item.get('max_connections_per_endpoint'),
u'maxRate': item.get('max_rate'),
u'maxRatePerInstance': item.get('max_rate_per_instance'),
u'maxRatePerEndpoint': item.get('max_rate_per_endpoint'),
u'maxUtilization': item.get('max_utilization'),
}
)
def _response_from_item(self, item):
return remove_nones_from_dict(
{
u'balancingMode': item.get(u'balancingMode'),
u'capacityScaler': item.get(u'capacityScaler'),
u'description': item.get(u'description'),
u'group': item.get(u'group'),
u'maxConnections': item.get(u'maxConnections'),
u'maxConnectionsPerInstance': item.get(u'maxConnectionsPerInstance'),
u'maxConnectionsPerEndpoint': item.get(u'maxConnectionsPerEndpoint'),
u'maxRate': item.get(u'maxRate'),
u'maxRatePerInstance': item.get(u'maxRatePerInstance'),
u'maxRatePerEndpoint': item.get(u'maxRatePerEndpoint'),
u'maxUtilization': item.get(u'maxUtilization'),
}
)
class BackendServiceCdnpolicy(object):
def __init__(self, request, module):
self.module = module
if request:
self.request = request
else:
self.request = {}
def to_request(self):
return remove_nones_from_dict(
{
u'cacheKeyPolicy': BackendServiceCachekeypolicy(self.request.get('cache_key_policy', {}), self.module).to_request(),
u'signedUrlCacheMaxAgeSec': self.request.get('signed_url_cache_max_age_sec'),
}
)
def from_response(self):
return remove_nones_from_dict(
{
u'cacheKeyPolicy': BackendServiceCachekeypolicy(self.request.get(u'cacheKeyPolicy', {}), self.module).from_response(),
u'signedUrlCacheMaxAgeSec': self.request.get(u'signedUrlCacheMaxAgeSec'),
}
)
class BackendServiceCachekeypolicy(object):
def __init__(self, request, module):
self.module = module
if request:
self.request = request
else:
self.request = {}
def to_request(self):
return remove_nones_from_dict(
{
u'includeHost': self.request.get('include_host'),
u'includeProtocol': self.request.get('include_protocol'),
u'includeQueryString': self.request.get('include_query_string'),
u'queryStringBlacklist': self.request.get('query_string_blacklist'),
u'queryStringWhitelist': self.request.get('query_string_whitelist'),
}
)
def from_response(self):
return remove_nones_from_dict(
{
u'includeHost': self.request.get(u'includeHost'),
u'includeProtocol': self.request.get(u'includeProtocol'),
u'includeQueryString': self.request.get(u'includeQueryString'),
u'queryStringBlacklist': self.request.get(u'queryStringBlacklist'),
u'queryStringWhitelist': self.request.get(u'queryStringWhitelist'),
}
)
class BackendServiceConnectiondraining(object):
def __init__(self, request, module):
self.module = module
if request:
self.request = request
else:
self.request = {}
def to_request(self):
return remove_nones_from_dict({u'drainingTimeoutSec': self.request.get('draining_timeout_sec')})
def from_response(self):
return remove_nones_from_dict({u'drainingTimeoutSec': self.request.get(u'drainingTimeoutSec')})
class BackendServiceIap(object):
def __init__(self, request, module):
self.module = module
if request:
self.request = request
else:
self.request = {}
def to_request(self):
return remove_nones_from_dict(
{
u'enabled': self.request.get('enabled'),
u'oauth2ClientId': self.request.get('oauth2_client_id'),
u'oauth2ClientSecret': self.request.get('oauth2_client_secret'),
}
)
def from_response(self):
return remove_nones_from_dict(
{
u'enabled': self.request.get(u'enabled'),
u'oauth2ClientId': self.request.get(u'oauth2ClientId'),
u'oauth2ClientSecret': self.request.get(u'oauth2ClientSecret'),
}
)
if __name__ == '__main__':
main()
| thaim/ansible | lib/ansible/modules/cloud/google/gcp_compute_backend_service.py | Python | mit | 44,362 | [
30522,
1001,
999,
1013,
30524,
1058,
2509,
1012,
1014,
1009,
1006,
2156,
24731,
2030,
16770,
1024,
1013,
1013,
7479,
1012,
27004,
1012,
8917,
1013,
15943,
1013,
14246,
2140,
1011,
1017,
1012,
1014,
1012,
19067,
2102,
1007,
1001,
1011,
1011,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>type property - OListElement class - polymer_app_layout.behaviors library - Dart API</title>
<!-- required because all the links are pseudo-absolute -->
<base href="../..">
<link href='https://fonts.googleapis.com/css?family=Source+Code+Pro|Roboto:500,400italic,300,400' rel='stylesheet' type='text/css'>
<link rel="stylesheet" href="static-assets/prettify.css">
<link rel="stylesheet" href="static-assets/css/bootstrap.min.css">
<link rel="stylesheet" href="static-assets/styles.css">
<meta name="description" content="API docs for the type property from the OListElement class, for the Dart programming language.">
<link rel="icon" href="static-assets/favicon.png">
<!-- Do not remove placeholder -->
<!-- Header Placeholder -->
</head>
<body>
<div id="overlay-under-drawer"></div>
<header class="container-fluid" id="title">
<nav class="navbar navbar-fixed-top">
<div class="container">
<button id="sidenav-left-toggle" type="button"> </button>
<ol class="breadcrumbs gt-separated hidden-xs">
<li><a href="index.html">polymer_app_layout_template</a></li>
<li><a href="polymer_app_layout.behaviors/polymer_app_layout.behaviors-library.html">polymer_app_layout.behaviors</a></li>
<li><a href="polymer_app_layout.behaviors/OListElement-class.html">OListElement</a></li>
<li class="self-crumb">type</li>
</ol>
<div class="self-name">type</div>
</div>
</nav>
<div class="container masthead">
<ol class="breadcrumbs gt-separated visible-xs">
<li><a href="index.html">polymer_app_layout_template</a></li>
<li><a href="polymer_app_layout.behaviors/polymer_app_layout.behaviors-library.html">polymer_app_layout.behaviors</a></li>
<li><a href="polymer_app_layout.behaviors/OListElement-class.html">OListElement</a></li>
<li class="self-crumb">type</li>
</ol>
<div class="title-description">
<h1 class="title">
<div class="kind">property</div> type
</h1>
<!-- p class="subtitle">
</p -->
</div>
<ul class="subnav">
</ul>
</div>
</header>
<div class="container body">
<div class="col-xs-6 col-sm-3 sidebar sidebar-offcanvas-left">
<h5><a href="index.html">polymer_app_layout_template</a></h5>
<h5><a href="polymer_app_layout.behaviors/polymer_app_layout.behaviors-library.html">polymer_app_layout.behaviors</a></h5>
<h5><a href="polymer_app_layout.behaviors/OListElement-class.html">OListElement</a></h5>
<ol>
<li class="section-title"><a href="polymer_app_layout.behaviors/OListElement-class.html#instance-properties">Properties</a></li>
<li>attributes
</li>
<li>baseUri
</li>
<li>borderEdge
</li>
<li>childNodes
</li>
<li>children
</li>
<li>classes
</li>
<li>className
</li>
<li>client
</li>
<li>clientHeight
</li>
<li>clientLeft
</li>
<li>clientTop
</li>
<li>clientWidth
</li>
<li>contentEdge
</li>
<li>contentEditable
</li>
<li>contextMenu
</li>
<li>dataset
</li>
<li>dir
</li>
<li>documentOffset
</li>
<li>draggable
</li>
<li>dropzone
</li>
<li>firstChild
</li>
<li>hidden
</li>
<li>id
</li>
<li>innerHtml
</li>
<li>inputMethodContext
</li>
<li>isContentEditable
</li>
<li>lang
</li>
<li>lastChild
</li>
<li>localName
</li>
<li>marginEdge
</li>
<li>namespaceUri
</li>
<li>nextElementSibling
</li>
<li>nextNode
</li>
<li>nodeName
</li>
<li>nodes
</li>
<li>nodeType
</li>
<li>nodeValue
</li>
<li>offset
</li>
<li>offsetHeight
</li>
<li>offsetLeft
</li>
<li>offsetParent
</li>
<li>offsetTop
</li>
<li>offsetWidth
</li>
<li>on
</li>
<li>onAbort
</li>
<li>onBeforeCopy
</li>
<li>onBeforeCut
</li>
<li>onBeforePaste
</li>
<li>onBlur
</li>
<li>onCanPlay
</li>
<li>onCanPlayThrough
</li>
<li>onChange
</li>
<li>onClick
</li>
<li>onContextMenu
</li>
<li>onCopy
</li>
<li>onCut
</li>
<li>onDoubleClick
</li>
<li>onDrag
</li>
<li>onDragEnd
</li>
<li>onDragEnter
</li>
<li>onDragLeave
</li>
<li>onDragOver
</li>
<li>onDragStart
</li>
<li>onDrop
</li>
<li>onDurationChange
</li>
<li>onEmptied
</li>
<li>onEnded
</li>
<li>onError
</li>
<li>onFocus
</li>
<li>onFullscreenChange
</li>
<li>onFullscreenError
</li>
<li>onInput
</li>
<li>onInvalid
</li>
<li>onKeyDown
</li>
<li>onKeyPress
</li>
<li>onKeyUp
</li>
<li>onLoad
</li>
<li>onLoadedData
</li>
<li>onLoadedMetadata
</li>
<li>onMouseDown
</li>
<li>onMouseEnter
</li>
<li>onMouseLeave
</li>
<li>onMouseMove
</li>
<li>onMouseOut
</li>
<li>onMouseOver
</li>
<li>onMouseUp
</li>
<li>onMouseWheel
</li>
<li>onPaste
</li>
<li>onPause
</li>
<li>onPlay
</li>
<li>onPlaying
</li>
<li>onRateChange
</li>
<li>onReset
</li>
<li>onResize
</li>
<li>onScroll
</li>
<li>onSearch
</li>
<li>onSeeked
</li>
<li>onSeeking
</li>
<li>onSelect
</li>
<li>onSelectStart
</li>
<li>onStalled
</li>
<li>onSubmit
</li>
<li>onSuspend
</li>
<li>onTimeUpdate
</li>
<li>onTouchCancel
</li>
<li>onTouchEnd
</li>
<li>onTouchEnter
</li>
<li>onTouchLeave
</li>
<li>onTouchMove
</li>
<li>onTouchStart
</li>
<li>onTransitionEnd
</li>
<li>onVolumeChange
</li>
<li>onWaiting
</li>
<li>outerHtml
</li>
<li>ownerDocument
</li>
<li>paddingEdge
</li>
<li>parent
</li>
<li>parentNode
</li>
<li>previousElementSibling
</li>
<li>previousNode
</li>
<li><a href="polymer_app_layout.behaviors/OListElement/reversed.html">reversed</a>
</li>
<li>scrollHeight
</li>
<li>scrollLeft
</li>
<li>scrollTop
</li>
<li>scrollWidth
</li>
<li>shadowRoot
</li>
<li>spellcheck
</li>
<li><a href="polymer_app_layout.behaviors/OListElement/start.html">start</a>
</li>
<li>style
</li>
<li>tabIndex
</li>
<li>tagName
</li>
<li>text
</li>
<li>title
</li>
<li>translate
</li>
<li><a href="polymer_app_layout.behaviors/OListElement/type.html">type</a>
</li>
<li>xtag
</li>
<li class="section-title"><a href="polymer_app_layout.behaviors/OListElement-class.html#constructors">Constructors</a></li>
<li><a href="polymer_app_layout.behaviors/OListElement/OListElement.html">OListElement</a></li>
<li><a href="polymer_app_layout.behaviors/OListElement/OListElement.created.html">created</a></li>
<li class="section-title"><a href="polymer_app_layout.behaviors/OListElement-class.html#methods">Methods</a></li>
<li>addEventListener
</li>
<li>animate
</li>
<li>append
</li>
<li>appendHtml
</li>
<li>appendText
</li>
<li>attached
</li>
<li>attributeChanged
</li>
<li>blur
</li>
<li>click
</li>
<li>clone
</li>
<li>contains
</li>
<li>createFragment
</li>
<li>createShadowRoot
</li>
<li>detached
</li>
<li>dispatchEvent
</li>
<li>enteredView
</li>
<li>focus
</li>
<li>getAnimationPlayers
</li>
<li>getAttribute
</li>
<li>getAttributeNS
</li>
<li>getBoundingClientRect
</li>
<li>getClientRects
</li>
<li>getComputedStyle
</li>
<li>getDestinationInsertionPoints
</li>
<li>getElementsByClassName
</li>
<li>getNamespacedAttributes
</li>
<li>hasChildNodes
</li>
<li>insertAdjacentElement
</li>
<li>insertAdjacentHtml
</li>
<li>insertAdjacentText
</li>
<li>insertAllBefore
</li>
<li>insertBefore
</li>
<li>leftView
</li>
<li>matches
</li>
<li>matchesWithAncestors
</li>
<li>offsetTo
</li>
<li>query
</li>
<li>queryAll
</li>
<li>querySelector
</li>
<li>querySelectorAll
</li>
<li>remove
</li>
<li>removeEventListener
</li>
<li>replaceWith
</li>
<li>requestFullscreen
</li>
<li>requestPointerLock
</li>
<li>scrollIntoView
</li>
<li>setAttribute
</li>
<li>setAttributeNS
</li>
<li>setInnerHtml
</li>
<li>toString
</li>
</ol>
</div><!--/.sidebar-offcanvas-->
<div class="col-xs-12 col-sm-9 col-md-6 main-content">
<section class="multi-line-signature">
<span class="returntype">String</span>
<span class="name ">type</span>
<div class="readable-writable">
read / write
</div>
</section>
<section class="desc markdown">
<p class="no-docs">Not documented.</p>
</section>
</div> <!-- /.main-content -->
</div> <!-- container -->
<footer>
<div class="container-fluid">
<div class="container">
<p class="text-center">
<span class="no-break">
polymer_app_layout_template 0.1.0 api docs
</span>
•
<span class="copyright no-break">
<a href="https://www.dartlang.org">
<img src="static-assets/favicon.png" alt="Dart" title="Dart"width="16" height="16">
</a>
</span>
•
<span class="copyright no-break">
<a href="http://creativecommons.org/licenses/by-sa/4.0/">cc license</a>
</span>
</p>
</div>
</div>
</footer>
<script src="static-assets/prettify.js"></script>
<script src="static-assets/script.js"></script>
<!-- Do not remove placeholder -->
<!-- Footer Placeholder -->
</body>
</html>
| lejard-h/polymer_app_layout_templates | doc/api/polymer_app_layout.behaviors/OListElement/type.html | HTML | bsd-3-clause | 10,287 | [
30522,
1026,
999,
9986,
13874,
16129,
1028,
1026,
16129,
11374,
1027,
1000,
4372,
1000,
1028,
1026,
2132,
1028,
1026,
18804,
25869,
13462,
1027,
1000,
21183,
2546,
1011,
1022,
1000,
1028,
1026,
18804,
8299,
1011,
1041,
15549,
2615,
1027,
10... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
/*---------------------------------------------------------------------------*\
## #### ###### |
## ## ## | Copyright: ICE Stroemungsfoschungs GmbH
## ## #### |
## ## ## | http://www.ice-sf.at
## #### ###### |
-------------------------------------------------------------------------------
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright held by original author
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is based on OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Class
Foam::faForceEquation
Description
Force a fvMatrix to fixed values in specific places
SourceFiles
faForceEquation.C
Contributors/Copyright:
2011, 2013-2014 Bernhard F.W. Gschaider <bgschaid@ice-sf.at>
SWAK Revision: $Id$
\*---------------------------------------------------------------------------*/
#ifndef faForceEquation_H
#define faForceEquation_H
#include "FaFieldValueExpressionDriver.H"
#include "faMatrix.H"
#include "DynamicList.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class faForceEquation Declaration
\*---------------------------------------------------------------------------*/
template<class T>
class faForceEquation
:
protected FaFieldValueExpressionDriver
{
// Private data
faForceEquation(const faForceEquation&);
string valueExpression_;
string maskExpression_;
bool verbose_;
bool getMask(DynamicList<label> &,const word &psi);
public:
// Constructors
//- Construct from a dictionary
faForceEquation
(
const dictionary& ,
const fvMesh&
);
// Destructor
virtual ~faForceEquation();
//- fix equations
void operator()(faMatrix<T> &);
//- where are the equations fixed
tmp<areaScalarField> getMask();
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //
| Unofficial-Extend-Project-Mirror/openfoam-extend-Breeder1.7-libraries-swak4Foam | Libraries/swakFiniteArea/expressionSource/faForceEquation.H | C++ | gpl-2.0 | 3,071 | [
30522,
1013,
1008,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
101... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
/*
* Copyright 2006-2020 The MZmine Development Team
*
* This file is part of MZmine.
*
* MZmine is free software; you can redistribute it and/or modify it under the terms of the GNU
* General Public License as published by the Free Software Foundation; either version 2 of the
* License, or (at your option) any later version.
*
* MZmine is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even
* the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
* Public License for more details.
*
* You should have received a copy of the GNU General Public License along with MZmine; if not,
* write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
* USA
*/
package io.github.mzmine.parameters.parametertypes.ranges;
import java.text.NumberFormat;
import java.util.Collection;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.NodeList;
import com.google.common.collect.Range;
import io.github.mzmine.parameters.UserParameter;
public class DoubleRangeParameter implements UserParameter<Range<Double>, DoubleRangeComponent> {
private final String name, description;
protected final boolean valueRequired;
private final boolean nonEmptyRequired;
private NumberFormat format;
private Range<Double> value;
private Range<Double> maxAllowedRange;
public DoubleRangeParameter(String name, String description, NumberFormat format) {
this(name, description, format, true, false, null);
}
public DoubleRangeParameter(String name, String description, NumberFormat format,
Range<Double> defaultValue) {
this(name, description, format, true, false, defaultValue);
}
public DoubleRangeParameter(String name, String description, NumberFormat format,
boolean valueRequired, Range<Double> defaultValue) {
this(name, description, format, valueRequired, false, defaultValue);
}
public DoubleRangeParameter(String name, String description, NumberFormat format,
boolean valueRequired, boolean nonEmptyRequired, Range<Double> defaultValue) {
this(name, description, format, valueRequired, nonEmptyRequired, defaultValue, null);
}
public DoubleRangeParameter(String name, String description, NumberFormat format,
boolean valueRequired, boolean nonEmptyRequired, Range<Double> defaultValue, Range<Double> maxAllowedRange) {
this.name = name;
this.description = description;
this.format = format;
this.valueRequired = valueRequired;
this.nonEmptyRequired = nonEmptyRequired;
this.value = defaultValue;
this.maxAllowedRange = maxAllowedRange;
}
/**
* @see io.github.mzmine.data.Parameter#getName()
*/
@Override
public String getName() {
return name;
}
/**
* @see io.github.mzmine.data.Parameter#getDescription()
*/
@Override
public String getDescription() {
return description;
}
public boolean isValueRequired() {
return valueRequired;
}
@Override
public DoubleRangeComponent createEditingComponent() {
return new DoubleRangeComponent(format);
}
public Range<Double> getValue() {
return value;
}
@Override
public void setValue(Range<Double> value) {
this.value = value;
}
@Override
public DoubleRangeParameter cloneParameter() {
DoubleRangeParameter copy = new DoubleRangeParameter(name, description, format);
copy.setValue(this.getValue());
return copy;
}
@Override
public void setValueFromComponent(DoubleRangeComponent component) {
value = component.getValue();
}
@Override
public void setValueToComponent(DoubleRangeComponent component, Range<Double> newValue) {
component.setValue(newValue);
}
@Override
public void loadValueFromXML(Element xmlElement) {
NodeList minNodes = xmlElement.getElementsByTagName("min");
if (minNodes.getLength() != 1)
return;
NodeList maxNodes = xmlElement.getElementsByTagName("max");
if (maxNodes.getLength() != 1)
return;
String minText = minNodes.item(0).getTextContent();
String maxText = maxNodes.item(0).getTextContent();
double min = Double.valueOf(minText);
double max = Double.valueOf(maxText);
value = Range.closed(min, max);
}
@Override
public void saveValueToXML(Element xmlElement) {
if (value == null)
return;
Document parentDocument = xmlElement.getOwnerDocument();
Element newElement = parentDocument.createElement("min");
newElement.setTextContent(String.valueOf(value.lowerEndpoint()));
xmlElement.appendChild(newElement);
newElement = parentDocument.createElement("max");
newElement.setTextContent(String.valueOf(value.upperEndpoint()));
xmlElement.appendChild(newElement);
}
@Override
public boolean checkValue(Collection<String> errorMessages) {
if (valueRequired && (value == null)) {
errorMessages.add(name + " is not set properly");
return false;
}
if (value != null) {
if (!nonEmptyRequired && value.lowerEndpoint() > value.upperEndpoint()) {
errorMessages.add(name + " range maximum must be higher than minimum, or equal");
return false;
}
if (nonEmptyRequired && value.lowerEndpoint() >= value.upperEndpoint()) {
errorMessages.add(name + " range maximum must be higher than minimum");
return false;
}
}
if (value != null && maxAllowedRange != null) {
if (maxAllowedRange.intersection(value) != value) {
errorMessages.add(name + " must be within " + maxAllowedRange.toString());
return false;
}
}
return true;
}
}
| tomas-pluskal/mzmine3 | src/main/java/io/github/mzmine/parameters/parametertypes/ranges/DoubleRangeParameter.java | Java | gpl-2.0 | 5,669 | [
30522,
1013,
1008,
1008,
9385,
2294,
1011,
12609,
1996,
1049,
2480,
11233,
2458,
2136,
1008,
1008,
2023,
5371,
2003,
2112,
1997,
1049,
2480,
11233,
1012,
1008,
1008,
1049,
2480,
11233,
2003,
2489,
4007,
1025,
2017,
2064,
2417,
2923,
3089,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
<?php
/*
* This file is part of the Yoozi Golem package.
*
* (c) Yoozi Inc. <hello@yoozi.cn>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Yoozi\Email\Address;
/**
* Email address parser.
*
* @author Saturn HU <yangg.hu@yoozi.cn>
*/
class Parser
{
/**
* A list of common used email providers.
*
* @var array
*/
public static $providers = array(
'126.com' => 'http://www.126.com',
'139.com' => 'http://mail.139.com',
'163.com' => 'http://www.163.com',
'188.com' => 'http://www.188.com/',
'189.cn' => 'http://mail.189.cn/',
'21cn.com' => 'http://mail.21cn.com',
'2980.com' => 'http://www.2980.com/',
'aim.com' => 'http://webmail.aol.com/?offerId=aimmail-en-us',
'aliyun.com' => 'http://mail.aliyun.com/alimail/',
'aol.com' => 'http://webmail.aol.com',
'china.com' => 'http://mail.china.com/index.html',
'citiz.net' => 'http://www.citiz.net/cloudmail/',
'cntv.cn' => 'http://mail.china.com/index.html',
'eyou.com' => 'http://www.eyou.com',
'foxmail.com' => 'http://mail.qq.com/cgi-bin/loginpage',
'gmail.com' => 'http://mail.google.com',
'hexun.com' => 'http://mail.hexun.com',
'hotmail.com' => 'http://www.hotmail.com',
'icloud.com' => 'https://www.icloud.com/#mail',
'mail.com' => 'http://www.mail.com/int/',
'me.com' => 'https://www.icloud.com/#mail',
'msn.com' => 'https://accountservices.msn.com/',
'outlook.com' => 'http://www.outlook.com',
'qq.com' => 'http://mail.qq.com/cgi-bin/loginpage',
'renren.com' => 'http://mail.renren.com/',
'sina.cn' => 'http://mail.sina.cn',
'sina.com' => 'http://mail.sina.com',
'sogou.com' => 'http://mail.sogou.com/',
'sohu.com' => 'http://mail.sohu.com',
'tom.com' => 'http://mail.tom.com',
'vip.126.com' => 'http://vip.126.com',
'vip.163.com' => 'http://vip.163.com',
'vip.21cn.com' => 'http://vip.21cn.com',
'vip.citiz.net' => 'http://www.citiz.net/cloudmail/',
'vip.cntv.cn' => 'http://mail.china.com/index.html',
'vip.qq.com' => 'http://mail.qq.com/cgi-bin/loginpage',
'vip.sina.com' => 'http://vip.sina.com',
'vnet.citiz.net' => 'http://www.citiz.net/cloudmail/',
'wo.com.cn' => 'http://mail.wo.com.cn/mail/login.action',
'yahoo.com' => 'http://mail.yahoo.com',
'yeah.net' => 'http://www.yeah.net'
);
/**
* Holds the parsed segments.
*
* @var array
*/
protected $parts = array();
/**
* Create a new email address parser.
*
* @param array $providers
* @return void
*/
public function __construct(array $providers = array())
{
if ($providers) {
static::$providers = $providers;
}
}
/**
* Parse a email address, return the parsed parts.
*
* @param string $email
* @return array
*/
public function parse($email)
{
if (! filter_var($email, FILTER_VALIDATE_EMAIL)) {
throw new \InvalidArgumentException(
"\$email($email) is not a valid email address."
);
}
$email = strtolower($email);
list($local, $domain) = explode('@', $email);
$listed = isset(static::$providers[$domain]);
$url = $listed ? static::$providers[$domain] : 'http://mail.' . $domain;
return $this->parts = compact('email', 'local', 'domain', 'url', 'listed');
}
/**
* Get the list of providers.
*
* @return array
*/
public function getProviders()
{
return static::$providers;
}
/**
* The parsed result in array.
*
* @return array
*/
public function toArray()
{
return $this->parts;
}
/**
* The parsed result in json.
*
* @param int $options
* @return string
*/
public function toJson($options = 0)
{
return json_encode($this->parts, $options);
}
}
| yoozi/golem | lib/Yoozi/Email/Address/Parser.php | PHP | mit | 4,414 | [
30522,
1026,
1029,
25718,
1013,
1008,
1008,
2023,
5371,
2003,
2112,
1997,
1996,
26823,
5831,
2175,
16930,
7427,
1012,
1008,
1008,
1006,
1039,
1007,
26823,
5831,
4297,
1012,
1026,
7592,
1030,
26823,
5831,
1012,
27166,
1028,
1008,
1008,
2005,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
/*
* include/linux/writeback.h
*/
#ifndef WRITEBACK_H
#define WRITEBACK_H
#include <linux/sched.h>
#include <linux/fs.h>
struct backing_dev_info;
extern spinlock_t inode_lock;
extern struct list_head inode_in_use;
extern struct list_head inode_unused;
/*
* Yes, writeback.h requires sched.h
* No, sched.h is not included from here.
*/
static inline int task_is_pdflush(struct task_struct *task)
{
return task->flags & PF_FLUSHER;
}
#define current_is_pdflush() task_is_pdflush(current)
/*
* fs/fs-writeback.c
*/
enum writeback_sync_modes {
WB_SYNC_NONE, /* Don't wait on anything */
WB_SYNC_ALL, /* Wait on every mapping */
WB_SYNC_HOLD, /* Hold the inode on sb_dirty for sys_sync() */
};
/*
* A control structure which tells the writeback code what to do. These are
* always on the stack, and hence need no locking. They are always initialised
* in a manner such that unspecified fields are set to zero.
*/
struct writeback_control {
struct backing_dev_info *bdi; /* If !NULL, only write back this
queue */
enum writeback_sync_modes sync_mode;
unsigned long *older_than_this; /* If !NULL, only write back inodes
older than this */
long nr_to_write; /* Write this many pages, and decrement
this for each page written */
long pages_skipped; /* Pages which were not written */
/*
* For a_ops->writepages(): is start or end are non-zero then this is
* a hint that the filesystem need only write out the pages inside that
* byterange. The byte at `end' is included in the writeout request.
*/
loff_t range_start;
loff_t range_end;
unsigned nonblocking:1; /* Don't get stuck on request queues */
unsigned encountered_congestion:1; /* An output: a queue is full */
unsigned for_kupdate:1; /* A kupdate writeback */
unsigned for_reclaim:1; /* Invoked from the page allocator */
unsigned for_writepages:1; /* This is a writepages() call */
unsigned range_cyclic:1; /* range_start is cyclic */
unsigned more_io:1; /* more io to be dispatched */
unsigned range_cont:1;
};
/*
* fs/fs-writeback.c
*/
void writeback_inodes(struct writeback_control *wbc);
int inode_wait(void *);
void sync_inodes_sb(struct super_block *, int wait);
void sync_inodes(int wait);
/* writeback.h requires fs.h; it, too, is not included from here. */
static inline void wait_on_inode(struct inode *inode)
{
might_sleep();
wait_on_bit(&inode->i_state, __I_LOCK, inode_wait,
TASK_UNINTERRUPTIBLE);
}
static inline void inode_sync_wait(struct inode *inode)
{
might_sleep();
wait_on_bit(&inode->i_state, __I_SYNC, inode_wait,
TASK_UNINTERRUPTIBLE);
}
/*
* mm/page-writeback.c
*/
int wakeup_pdflush(long nr_pages);
void laptop_io_completion(void);
void laptop_sync_completion(void);
void throttle_vm_writeout(gfp_t gfp_mask);
/* These are exported to sysctl. */
extern int dirty_background_ratio;
extern int vm_dirty_ratio;
extern int dirty_writeback_interval;
extern int dirty_expire_interval;
extern int vm_highmem_is_dirtyable;
extern int block_dump;
extern int laptop_mode;
extern unsigned long determine_dirtyable_memory(void);
extern int dirty_ratio_handler(struct ctl_table *table, int write,
struct file *filp, void __user *buffer, size_t *lenp,
loff_t *ppos);
struct ctl_table;
struct file;
int dirty_writeback_centisecs_handler(struct ctl_table *, int, struct file *,
void __user *, size_t *, loff_t *);
void get_dirty_limits(long *pbackground, long *pdirty, long *pbdi_dirty,
struct backing_dev_info *bdi);
void page_writeback_init(void);
void balance_dirty_pages_ratelimited_nr(struct address_space *mapping,
unsigned long nr_pages_dirtied);
static inline void
balance_dirty_pages_ratelimited(struct address_space *mapping)
{
balance_dirty_pages_ratelimited_nr(mapping, 1);
}
typedef int (*writepage_t)(struct page *page, struct writeback_control *wbc,
void *data);
int pdflush_operation(void (*fn)(unsigned long), unsigned long arg0);
int generic_writepages(struct address_space *mapping,
struct writeback_control *wbc);
int write_cache_pages(struct address_space *mapping,
struct writeback_control *wbc, writepage_t writepage,
void *data);
int do_writepages(struct address_space *mapping, struct writeback_control *wbc);
int sync_page_range(struct inode *inode, struct address_space *mapping,
loff_t pos, loff_t count);
int sync_page_range_nolock(struct inode *inode, struct address_space *mapping,
loff_t pos, loff_t count);
void set_page_dirty_balance(struct page *page, int page_mkwrite);
void writeback_set_ratelimit(void);
/* pdflush.c */
extern int nr_pdflush_threads; /* Global so it can be exported to sysctl
read-only. */
#endif /* WRITEBACK_H */
| MicroTrustRepos/microkernel | src/l4/pkg/linux-26-headers/include/linux/writeback.h | C | gpl-2.0 | 4,719 | [
30522,
1013,
1008,
1008,
2421,
1013,
11603,
1013,
30524,
4339,
5963,
1035,
1044,
1001,
9375,
4339,
5963,
1035,
1044,
1001,
2421,
1026,
11603,
1013,
8040,
9072,
1012,
1044,
1028,
1001,
2421,
1026,
11603,
1013,
1042,
2015,
1012,
1044,
1028,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
# encoding: UTF-8
#
# Author: Stefano Harding <riddopic@gmail.com>
# License: Apache License, Version 2.0
# Copyright: (C) 2014-2015 Stefano Harding
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# Konstruktor is a set of helpers that makes constructor definition less
# verbose.
#
# @example
# Turn this:
# class Foo
# attr_reader :foo, :bar, :baz
#
# def initialize(foo, bar, baz)
# @foo = foo
# @bar = bar
# @baz = baz
# end
#
# def hello
# 'world'
# end
# end
#
# Into this:
# class Foo
# include Hoodie::Konstruktor
#
# takes :foo, :bar, :baz
# let(:hello) { 'world' }
# end
#
module Hoodie
module Konstruktor
def takes(*names)
attr_reader *names
include Hoodie::Constructor(*names)
extend Hoodie::Let
end
end
def self.Constructor(*names)
eval <<-RUBY
Module.new do
def initialize(#{names.join(', ')})
#{names.map{ |name| "@#{name} = #{name}" }.join("\n") }
end
end
RUBY
end
module Let
def let(name, &block)
define_method(name, &block)
end
end
end
class Object
extend Hoodie::Konstruktor
end
| riddopic/hoodie | lib/hoodie/utils/konstruktor.rb | Ruby | apache-2.0 | 1,699 | [
30522,
1001,
17181,
1024,
21183,
2546,
1011,
1022,
1001,
1001,
3166,
1024,
19618,
15456,
1026,
9436,
3527,
24330,
1030,
20917,
4014,
1012,
4012,
1028,
1001,
6105,
1024,
15895,
6105,
1010,
2544,
1016,
1012,
1014,
1001,
9385,
1024,
1006,
1039... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
file(REMOVE_RECURSE
"CMakeFiles/ORB_SLAM.dir/src/main.cc.o"
"CMakeFiles/ORB_SLAM.dir/src/Tracking.cc.o"
"CMakeFiles/ORB_SLAM.dir/src/LocalMapping.cc.o"
"CMakeFiles/ORB_SLAM.dir/src/LoopClosing.cc.o"
"CMakeFiles/ORB_SLAM.dir/src/ORBextractor.cc.o"
"CMakeFiles/ORB_SLAM.dir/src/ORBmatcher.cc.o"
"CMakeFiles/ORB_SLAM.dir/src/Converter.cc.o"
"CMakeFiles/ORB_SLAM.dir/src/MapPoint.cc.o"
"CMakeFiles/ORB_SLAM.dir/src/KeyFrame.cc.o"
"CMakeFiles/ORB_SLAM.dir/src/Map.cc.o"
"CMakeFiles/ORB_SLAM.dir/src/Optimizer.cc.o"
"CMakeFiles/ORB_SLAM.dir/src/PnPsolver.cc.o"
"CMakeFiles/ORB_SLAM.dir/src/Frame.cc.o"
"CMakeFiles/ORB_SLAM.dir/src/KeyFrameDatabase.cc.o"
"CMakeFiles/ORB_SLAM.dir/src/Sim3Solver.cc.o"
"CMakeFiles/ORB_SLAM.dir/src/Initializer.cc.o"
"../lib/libORB_SLAM.pdb"
"../lib/libORB_SLAM.so"
)
# Per-language clean rules from dependency scanning.
foreach(lang CXX)
include(CMakeFiles/ORB_SLAM.dir/cmake_clean_${lang}.cmake OPTIONAL)
endforeach()
| jokereactive/ORB_Android | slam/build/CMakeFiles/ORB_SLAM.dir/cmake_clean.cmake | CMake | bsd-2-clause | 983 | [
30522,
5371,
1006,
6366,
1035,
28667,
28393,
1000,
4642,
13808,
8873,
4244,
1013,
19607,
1035,
9555,
1012,
16101,
1013,
5034,
2278,
1013,
2364,
1012,
10507,
1012,
1051,
1000,
1000,
4642,
13808,
8873,
4244,
1013,
19607,
1035,
9555,
1012,
161... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
/* Copyright (c) 2010-2015, Delft University of Technology
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
* - Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
* - Redistributions in binary form must reproduce the above copyright notice, this list of
* conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
* - Neither the name of the Delft University of Technology nor the names of its contributors
* may be used to endorse or promote products derived from this software without specific
* prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
* GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
* OF THE POSSIBILITY OF SUCH DAMAGE.
*
* Changelog
* YYMMDD Author Comment
* 100903 K. Kumar File header and footer added.
* 100916 L. Abdulkadir File checked.
* 100929 K. Kumar Checked code by D. Dirkx added.
* 101110 K. Kumar Added raiseToIntegerExponent( ) function.
* 102410 D. Dirkx Minor comment changes during code check.
* 101213 K. Kumar Modified raiseToIntegerExponent( ) function;
* renamed raiseToIntegerPower( ).
* Added computeAbsoluteValue( ) functions.
* 110111 J. Melman Added computeModulo( ) function.
* 110202 K. Kumar Added overload for State* for computeLinearInterpolation( ).
* 110411 K. Kumar Added convertCartesianToSpherical( ) function.
* 110707 K. Kumar Added computeSampleMean( ), computeSampleVariance( ) functions.
* 110810 J. Leloux Corrected doxygen documentation (equations).
* 110824 J. Leloux Corrected doxygen documentation.
* 110905 S. Billemont Reorganized includes.
* Moved (con/de)structors and getter/setters to header.
* 120202 K. Kumar Moved linear interpolation functions into new Interpolators
* sub-directory.
* 120627 T. Secretin Removed obsolete function using State objects.
* 120716 D. Dirkx Updated with interpolator architecture.
* 130114 D. Dirkx Fixed iterator bug.
*
* References
* Press W.H., et al. Numerical Recipes in C++: The Art of Scientific Computing, Cambridge
* University Press, February 2002.
* Spiegel, M.R., Stephens, L.J. Statistics, Fourth Edition, Schaum's Outlines, McGraw-Hill,
* 2008.
*
* Notes
*
*/
#ifndef TUDAT_LINEAR_INTERPOLATOR_H
#define TUDAT_LINEAR_INTERPOLATOR_H
#include <Eigen/Core>
#include <map>
#include <vector>
#include <boost/array.hpp>
#include <boost/multi_array.hpp>
#include <boost/shared_ptr.hpp>
#include "Tudat/Mathematics/Interpolators/oneDimensionalInterpolator.h"
#include "Tudat/Mathematics/BasicMathematics/nearestNeighbourSearch.h"
#include "Tudat/Mathematics/Interpolators/lookupScheme.h"
namespace tudat
{
namespace interpolators
{
//! Linear interpolator class.
/*!
* This class is used to perform linear interpolation in a single dimension from a set of
* data in independent and dependent variables.
*/
template< typename IndependentVariableType, typename DependentVariableType >
class LinearInterpolator
: public OneDimensionalInterpolator< IndependentVariableType, DependentVariableType >
{
public:
// Using statements to prevent having to put 'this' everywhere in the code.
using OneDimensionalInterpolator< IndependentVariableType, DependentVariableType >::
dependentValues_;
using OneDimensionalInterpolator< IndependentVariableType, DependentVariableType >::
independentValues_;
using OneDimensionalInterpolator< IndependentVariableType, DependentVariableType >::
lookUpScheme_;
using Interpolator< IndependentVariableType, DependentVariableType >::interpolate;
//! Constructor from map of independent/dependent data.
/*!
* This constructor initializes the interpolator from a map containing independent variables
* as key and dependent variables as value. A look-up scheme can be provided to override the
* given default.
* \param dataMap Map containing independent variables as key and dependent variables as
* value.
* \param selectedLookupScheme Identifier of lookupscheme from enum. This algorithm is used
* to find the nearest lower data point in the independent variables when requesting
* interpolation.
*/
LinearInterpolator( const std::map< IndependentVariableType, DependentVariableType >& dataMap,
const AvailableLookupScheme selectedLookupScheme = huntingAlgorithm )
{
// Verify that the initialization variables are not empty.
if ( dataMap.size( ) == 0 )
{
boost::throw_exception( boost::enable_error_info( std::runtime_error(
"The vectors used in the linear interpolator initialization are empty." ) ) );
}
// Resize data vectors of independent/dependent values.
independentValues_.resize( dataMap.size( ) );
dependentValues_.resize( dataMap.size( ) );
// Fill data vectors with data from map.
int counter = 0;
for ( typename std::map< IndependentVariableType, DependentVariableType >::const_iterator
mapIterator = dataMap.begin( ); mapIterator != dataMap.end( ); mapIterator++ )
{
independentValues_[ counter ] = mapIterator->first;
dependentValues_[ counter ] = mapIterator->second;
counter++;
}
// Create lookup scheme from independent variable data points.
this->makeLookupScheme( selectedLookupScheme );
}
//! Constructor from vectors of independent/dependent data.
/*!
* This constructor initializes the interpolator from two vectors containing the independent
* variables and dependent variables. A look-up scheme can be provided to
* override the given default.
* \param independentValues Vector of values of independent variables that are used, must be
* sorted in ascending order.
* \param dependentValues Vector of values of dependent variables that are used.
* \param selectedLookupScheme Identifier of lookupscheme from enum. This algorithm is used
* to find the nearest lower data point in the independent variables when requesting
* interpolation.
*/
LinearInterpolator( const std::vector< IndependentVariableType >& independentValues,
const std::vector< DependentVariableType >& dependentValues,
const AvailableLookupScheme selectedLookupScheme = huntingAlgorithm )
{
// Verify that the initialization variables are not empty.
if ( independentValues.size( ) == 0 || dependentValues.size( ) == 0 )
{
boost::throw_exception( boost::enable_error_info( std::runtime_error(
"The vectors used in the linear interpolator initialization are empty." ) ) );
}
// Set data vectors.
independentValues_ = independentValues;
dependentValues_= dependentValues;
// Create lookup scheme from independent variable values
this->makeLookupScheme( selectedLookupScheme );
}
//! Default destructor
/*!
* Default destructor
*/
~LinearInterpolator( ){ }
//! Function interpolates dependent variable value at given independent variable value.
/*!
* Function interpolates dependent variable value at given independent variable value.
* \param independentVariableValue Value of independent variable at which interpolation
* is to take place.
* \return Interpolated value of dependent variable.
*/
DependentVariableType interpolate( const IndependentVariableType independentVariableValue )
{
// Lookup nearest lower index.
int newNearestLowerIndex = lookUpScheme_->findNearestLowerNeighbour(
independentVariableValue );
// Perform linear interpolation.
DependentVariableType interpolatedValue = dependentValues_[ newNearestLowerIndex ] +
( independentVariableValue - independentValues_[ newNearestLowerIndex ] ) /
( independentValues_[ newNearestLowerIndex + 1 ] -
independentValues_[ newNearestLowerIndex ] ) *
( dependentValues_[ newNearestLowerIndex + 1 ] -
dependentValues_[ newNearestLowerIndex ] );
return interpolatedValue;
}
};
//! Typedef for linear interpolator with (in)dependent variable = double.
typedef LinearInterpolator< double, double > LinearInterpolatorDouble;
//! Typedef for shared-pointer to linear interpolator with (in)dependent variable = double.
typedef boost::shared_ptr< LinearInterpolatorDouble > LinearInterpolatorDoublePointer;
//! Compute linear interpolation free function.
/*!
* Computes linear interpolation of data provided in the form of a vector of
* sorted indepedent variables and an associated vector of dependent variables.
* The linear interpolation equation used is:
* \f[
* y_{target} = x_{1} * ( 1 - mu ) + x_{2} * mu
* \f]
* where \f$ mu = \frac{ x_{target} - x_{1} } { x_{2} + x_{1} } \f$
* and \f$ x_{2} > x_{1} \f$.
* \param sortedIndependentVariables Vector of independent variables sorted.
* in ascending/descending order.
* \param associatedDependentVariables Vector of dependent variables
* associated with sorted vector of independent variables.
* \param targetIndependentVariableValue Target independent variable value
* in vector of sorted independent variables.
* \return Value of dependent variable associated with target independent
* value in vector of sorted independent variables.
*/
double computeLinearInterpolation( const Eigen::VectorXd& sortedIndependentVariables,
const Eigen::VectorXd& associatedDependentVariables,
const double targetIndependentVariableValue );
//! Compute linear interpolation free function.
/*!
* Computes linear interpolation of data provided in the form of a map of
* independent variables and associated vectors of dependent variables.
* The linear interpolation equation used is:
* \f[
* y_{target} = x_{1} * ( 1 - mu ) + x_{2} * mu
* \f]
* where \f$ \mu = \frac{ x_{target} - x_{1} } { x_{2} + x_{1} } \f$
* and \f$ x_{2} > x_{1} \f$.
* \param sortedIndepedentAndDependentVariables Map of sorted independent
* variables, in ascending/descending order, and associated
* dependent variables.
* \param targetIndependentVariableValue Target independent variable value
* in vector of sorted independent variables.
* \return Vector of dependent variable associated with target independent
* value in vector of sorted independent variables.
*/
Eigen::VectorXd computeLinearInterpolation(
const std::map< double, Eigen::VectorXd >& sortedIndepedentAndDependentVariables,
const double targetIndependentVariableValue );
} // namespace interpolators
} // namespace tudat
#endif // TUDAT_LINEAR_INTERPOLATOR_H
| magnific0/tudat-svn-mirror | Tudat/Mathematics/Interpolators/linearInterpolator.h | C | bsd-3-clause | 12,646 | [
30522,
1013,
1008,
9385,
1006,
1039,
1007,
2230,
1011,
2325,
1010,
3972,
6199,
2118,
1997,
2974,
1008,
2035,
2916,
9235,
1012,
1008,
1008,
25707,
1998,
2224,
1999,
3120,
1998,
12441,
3596,
1010,
2007,
2030,
2302,
14080,
1010,
2024,
1008,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
jsonp({"cep":"26010250","logradouro":"Rua Grijo","bairro":"Vila Santos Neto","cidade":"Nova Igua\u00e7u","uf":"RJ","estado":"Rio de Janeiro"});
| lfreneda/cepdb | api/v1/26010250.jsonp.js | JavaScript | cc0-1.0 | 144 | [
30522,
1046,
3385,
2361,
1006,
1063,
1000,
8292,
2361,
1000,
1024,
1000,
13539,
10790,
17788,
2692,
1000,
1010,
1000,
8833,
12173,
8162,
2080,
1000,
1024,
1000,
21766,
2050,
24665,
28418,
2080,
1000,
1010,
1000,
21790,
18933,
1000,
1024,
10... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
/*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
/*
* Copyright (c) 2015, Joyent, Inc.
*/
var url = require('url');
var assert = require('assert-plus');
var async = require('async');
var libuuid = require('libuuid');
var common = require('./common');
var vmTest = require('./lib/vm');
var MORAY = require('../lib/apis/moray');
var sortValidation = require('../lib/validation/sort.js');
var vmCommon = require('../lib/common/vm-common.js');
var client;
exports.setUp = function (callback) {
common.setUp(function (err, _client) {
assert.ifError(err);
assert.ok(_client, 'restify client');
client = _client;
callback();
});
};
/*
* Creates a marker object that can be used to paginate through ListVms's
* results. It returns an object that has the properties listed in the
* "markerKeys" array and the values for these keys are copied from the
* "vmObject" object.
*/
function buildMarker(vmObject, markerKeys) {
assert.object(vmObject, 'vmObject must be an object');
assert.arrayOfString(markerKeys, 'markerKeys must be an array of strings');
var marker = {};
markerKeys.forEach(function (markerKey) {
if (markerKey === 'tags')
marker[markerKey] = vmCommon.objectToTagFormat(vmObject[markerKey]);
else
marker[markerKey] = vmObject[markerKey];
});
return marker;
}
/*
* This function creates a large number of "test" VMs
* (VMs with alias='test--', unless otherwise specified), and then sends GET
* requests to /vms to retrieve them by chunks. It uses the "marker"
* querystring param to paginate through the results. It then makes sure that
* after going through all test VMs, a subsequent request returns an empty set.
* Finally, it checks that there's no overlap between the different chunks
* received.
*/
function testMarkerPagination(options, t, callback) {
options = options || {};
assert.object(options, 'options');
assert.object(t, 't');
assert.func(callback, 'callback');
var NB_TEST_VMS_TO_CREATE = options.nbTestVms || 200;
var LIMIT = NB_TEST_VMS_TO_CREATE / 2;
var moray = new MORAY(common.config.moray);
moray.connect();
var vmsCreationParams = options.vmsCreationParams || {};
assert.object(vmsCreationParams,
'options.vmsCreationParams must be an object');
assert.ok(typeof (options.sort === 'string') || options.sort === undefined,
'options.sort must be undefined or a string');
var queryStringObject = {
limit: LIMIT
};
if (vmsCreationParams.alias !== undefined)
queryStringObject.alias = vmTest.TEST_VMS_ALIAS +
vmsCreationParams.alias;
else
queryStringObject.alias = vmTest.TEST_VMS_ALIAS;
if (options.sort !== undefined)
queryStringObject.sort = options.sort;
var markerKeys = options.markerKeys || [];
assert.arrayOfString(markerKeys,
'options.markerKeys must be an array of strings');
moray.once('moray-ready', function () {
var firstVmsChunk;
var secondVmsChunk;
async.waterfall([
// Delete test VMs leftover from previous tests run
function deleteTestVms(next) {
vmTest.deleteTestVMs(moray, {}, function vmsDeleted(err) {
t.ifError(err, 'deleting test VMs should not error');
return next(err);
});
},
function createFakeVms(next) {
vmTest.createTestVMs(NB_TEST_VMS_TO_CREATE, moray,
{concurrency: 100}, vmsCreationParams,
function fakeVmsCreated(err, vmsUuid) {
moray.connection.close();
t.equal(vmsUuid.length,
NB_TEST_VMS_TO_CREATE,
NB_TEST_VMS_TO_CREATE
+ ' vms should have been created');
t.ifError(err, NB_TEST_VMS_TO_CREATE
+ ' vms should be created successfully');
return next(err);
});
},
function listFirstVmsChunk(next) {
var listVmsQuery = url.format({pathname: '/vms',
query: queryStringObject});
client.get(listVmsQuery, function (err, req, res, body) {
var lastItem;
t.ifError(err);
if (err)
return next(err);
t.equal(res.headers['x-joyent-resource-count'],
NB_TEST_VMS_TO_CREATE,
'x-joyent-resource-count header should be equal to '
+ NB_TEST_VMS_TO_CREATE);
t.equal(body.length, LIMIT,
LIMIT + ' vms should be returned from first list vms');
lastItem = body[body.length - 1];
var marker = buildMarker(lastItem, markerKeys);
firstVmsChunk = body;
return next(null, JSON.stringify(marker));
});
},
function listNextVmsChunk(marker, next) {
assert.string(marker, 'marker');
queryStringObject.marker = marker;
var listVmsQuery = url.format({pathname: '/vms',
query: queryStringObject});
client.get(listVmsQuery, function (err, req, res, body) {
var lastItem;
t.ifError(err);
if (err)
return next(err);
t.equal(res.headers['x-joyent-resource-count'],
NB_TEST_VMS_TO_CREATE,
'x-joyent-resource-count header should be equal to '
+ NB_TEST_VMS_TO_CREATE);
t.equal(body.length, LIMIT,
'second vms list request should return ' + LIMIT
+ ' vms');
lastItem = body[body.length - 1];
var nextMarker = buildMarker(lastItem, markerKeys);
secondVmsChunk = body;
return next(null, JSON.stringify(nextMarker));
});
},
function listLastVmsChunk(marker, next) {
assert.string(marker, 'marker must be a string');
queryStringObject.marker = marker;
var listVmsQuery = url.format({pathname: '/vms',
query: queryStringObject});
client.get(listVmsQuery, function (err, req, res, body) {
t.ifError(err);
if (err)
return next(err);
t.equal(res.headers['x-joyent-resource-count'],
NB_TEST_VMS_TO_CREATE,
'x-joyent-resource-count header should be equal to '
+ NB_TEST_VMS_TO_CREATE);
t.equal(body.length, 0,
'last vms list request should return no vm');
return next();
});
},
function checkNoOverlap(next) {
function getVmUuid(vm) {
assert.object(vm, 'vm must be an object');
return vm.uuid;
}
var firstVmsChunkUuids = firstVmsChunk.map(getVmUuid);
var secondVmsChunkUuids = secondVmsChunk.map(getVmUuid);
var chunksOverlap = firstVmsChunkUuids.some(function (vmUuid) {
return secondVmsChunkUuids.indexOf(vmUuid) !== -1;
});
t.equal(chunksOverlap, false,
'subsequent responses should not overlap');
return next();
}
], function allDone(err, results) {
t.ifError(err);
return callback();
});
});
}
/*
* Checks that invalid markers result in the response containing
* the proper error status code and error message.
*/
exports.list_vms_marker_not_valid_JSON_object_not_ok = function (t) {
async.eachSeries([
'["uuid: 00000000-0000-0000-0000-000000000000"]',
'00000000-0000-0000-0000-000000000000',
'""',
''
], function testBadMarker(badMarker, next) {
var expectedError = {
code: 'ValidationFailed',
message: 'Invalid Parameters',
errors: [ {
field: 'marker',
code: 'Invalid',
message: 'Invalid marker: ' + JSON.stringify(badMarker) +
'. Marker must represent an object.'
}]
};
return common.testListInvalidParams(client,
{marker: JSON.stringify(badMarker)}, expectedError, t, next);
}, function allDone(err) {
t.done();
});
};
/*
* Using offset and marker params in the same request is not valid.
* Check that using them both in the same request results in the
* response having the proper error code and message.
*/
exports.list_vms_offset_and_marker_not_ok = function (t) {
var FAKE_VM_UUID = '00000000-0000-0000-0000-000000000000';
var marker = {
uuid: FAKE_VM_UUID
};
var queryString = '/vms?offset=1&marker=' + JSON.stringify(marker);
client.get(queryString, function (err, req, res, body) {
t.equal(res.statusCode, 409);
t.deepEqual(body, {
code: 'ValidationFailed',
message: 'Invalid Parameters',
errors: [ {
fields: ['offset', 'marker'],
code: 'ConflictingParameters',
message: 'offset and marker cannot be used at the same time'
} ]
});
t.done();
});
};
/*
* Checks that using the only key that can establish a strict total order
* as a marker to paginate through a test VMs set works as expected,
* without any error.
*/
exports.list_vms_marker_ok = function (t) {
testMarkerPagination({
markerKeys: ['uuid']
}, t, function testDone() {
t.done();
});
};
/*
* Cleanup test VMs created by the previous test (list_vms_marker_ok).
*/
exports.delete_test_vms_marker_ok = function (t) {
var moray = new MORAY(common.config.moray);
moray.connect();
moray.once('moray-ready', function () {
vmTest.deleteTestVMs(moray, {}, function testVmsDeleted(err) {
moray.connection.close();
t.ifError(err, 'deleting fake VMs should not error');
t.done();
});
});
};
/*
* Same test as list_vms_marker_ok, but adding a sort param on uuid ascending.
* Check that it works successfully as expected.
*/
exports.list_vms_marker_and_sort_on_uuid_asc_ok = function (t) {
testMarkerPagination({
sort: 'uuid.ASC',
markerKeys: ['uuid']
}, t, function testDone() {
t.done();
});
};
/*
* Cleanup test VMs created by the previous test
* (list_vms_marker_and_sort_on_uuid_asc_ok).
*/
exports.delete_test_vms_marker_and_sort_on_uuid_asc_ok = function (t) {
var moray = new MORAY(common.config.moray);
moray.connect();
moray.once('moray-ready', function () {
vmTest.deleteTestVMs(moray, {}, function testVmsDeleted(err) {
moray.connection.close();
t.ifError(err, 'deleting fake VMs should not error');
t.done();
});
});
};
/*
* Same test as list_vms_marker_ok, but adding a sort param on uuid descending.
* Check that it works successfully as expected.
*/
exports.list_vms_marker_and_sort_on_uuid_desc_ok = function (t) {
testMarkerPagination({
sort: 'uuid.DESC',
markerKeys: ['uuid']
}, t, function testDone() {
t.done();
});
};
/*
* Cleanup test VMs created by the previous test
* (list_vms_marker_and_sort_on_uuid_desc_ok).
*/
exports.delete_test_vms_marker_and_sort_on_uuid_desc_ok = function (t) {
var moray = new MORAY(common.config.moray);
moray.connect();
moray.once('moray-ready', function () {
vmTest.deleteTestVMs(moray, {}, function testVmsDeleted(err) {
moray.connection.close();
t.ifError(err, 'deleting fake VMs should not error');
t.done();
});
});
};
exports.marker_key_not_in_sort_field_not_ok = function (t) {
var TEST_MARKER = {create_timestamp: Date.now(), uuid: libuuid.create()};
var expectedError = {
code: 'ValidationFailed',
message: 'Invalid Parameters',
errors: [ {
field: 'marker',
code: 'Invalid',
message: 'Invalid marker: ' + JSON.stringify(TEST_MARKER) +
'. All marker keys except uuid must be present in the sort ' +
'parameter. Sort fields: undefined.'
} ]
};
common.testListInvalidParams(client,
{marker: JSON.stringify(TEST_MARKER)}, expectedError, t,
function testDone(err) {
t.done();
});
};
/*
* Most sort parameters do not allow to establish a strict total order relation
* between all VMs. For instance, sorting on "create_timestamp" and paginating
* through results by using the create_timestamp property as a marker,
* it is possible that two VM objects have the same create_timestamp. When
* sending the create_timestamp value of the latest VM item from the first page
* of results as a marker to get the second page of results, the server cannot
* tell which one of the two VMs the marker represents, and thus results can
* be unexpected.
*
* In order to be able to "break the tie", an attribute of VMs that allows
* to establish a strict total order has to be specified in the marker.
* Currently, the only attribute that has this property is "uuid".
*
* For each VM attribute on which users can sort that do not provide a strict
* total order, the tests below a series of tests that uses each sort criteria
* and a variety of marker configurations to make sure that the implementation
* behaves as expected.
*/
/*
* This table associates each sort key that doesn't provide a strict
* total order with a constant value. These constant values are used
* for all VMs of a test data set, so that using only these keys in
* a marker to identify the first item of the next page of results is
* not sufficient.
*/
var NON_STRICT_TOTAL_ORDER_SORT_KEYS = {
owner_uuid: libuuid.create(),
image_uuid: libuuid.create(),
billing_id: libuuid.create(),
server_uuid: libuuid.create(),
package_name: 'package_name_foo',
package_version: 'package_version_foo',
tags: vmCommon.objectToTagFormat({sometag: 'foo'}),
brand: 'foobrand',
state: 'test',
alias: 'test--marker-pagination',
max_physical_memory: 42,
create_timestamp: Date.now(),
docker: true
};
/*
* Given a sort key, creates a set of tests that check a few expected
* behaviors with that key.
*/
function createMarkerTests(sortKey, exports) {
assert.string(sortKey, 'sortKey must be a string');
assert.object(exports, 'exports must be an object');
sortValidation.VALID_SORT_ORDERS.forEach(function (sortOrder) {
createValidMarkerTest(sortKey, sortOrder, exports);
createDeleteVMsTest(sortKey, sortOrder, exports);
createSortKeyNotInMarkerTest(sortKey, sortOrder, exports);
createNoStrictTotalOrderKeyInMarkerTest(sortKey, sortOrder, exports);
});
}
/*
* Given a sort key and a sort order, it creates a fake data set with the same
* value for the property "sortKey". Then, it paginates through this data set
* by using a marker composed of the sort key and "uuid" (which establishes a
* strict total order) and checks that it can paginate through the all results
* set without any error and duplicate entries.
*/
function createValidMarkerTest(sortKey, sortOrder, exports) {
var newTestName = 'list_vms_marker_with_identical_' + sortKey + '_' +
sortOrder + '_ok';
var vmsCreationParams = {};
vmsCreationParams[sortKey] =
NON_STRICT_TOTAL_ORDER_SORT_KEYS[sortKey];
exports[newTestName] = function (t) {
testMarkerPagination({
sort: sortKey + '.' + sortOrder,
markerKeys: [sortKey, 'uuid'],
vmsCreationParams: vmsCreationParams
}, t, function testDone() {
t.done();
});
};
}
/*
* Creates a test that deletes the fake VMs created by the tests created
* by createValidMarkerTest.
*/
function createDeleteVMsTest(sortKey, sortOrder, exports) {
var clearVmsTestName = 'delete_test_vms_marker_with_identical_' + sortKey +
'_' + sortOrder + '_ok';
exports[clearVmsTestName] = function (t) {
var moray = new MORAY(common.config.moray);
moray.connect();
moray.once('moray-ready', function () {
vmTest.deleteTestVMs(moray, {}, function testVmsDeleted(err) {
moray.connection.close();
t.ifError(err, 'deleting fake VMs should not error');
t.done();
});
});
};
}
/*
* Creates a test that makes sure that when using sort to list VMs and a
* marker, not adding the sort key to the marker results in the proper error
* being sent.
*/
function createSortKeyNotInMarkerTest(sortKey, sortOrder, exports) {
var testName = 'list_vms_marker_sortkey_' + sortKey + '_' + sortOrder +
'_not_in_marker_not_ok';
var TEST_MARKER = {uuid: 'some-uuid'};
var TEST_SORT_PARAM = sortKey + '.' + sortOrder;
var expectedError = {
code: 'ValidationFailed',
message: 'Invalid Parameters',
errors: [ {
field: 'marker',
code: 'Invalid',
message: 'Invalid marker: ' + JSON.stringify(TEST_MARKER) +
'. All sort fields must be present in marker. Sort fields: ' +
TEST_SORT_PARAM + '.'
} ]
};
exports[testName] = function (t) {
common.testListInvalidParams(client,
{marker: JSON.stringify(TEST_MARKER), sort: TEST_SORT_PARAM},
expectedError, t,
function testDone(err) {
t.done();
});
};
}
/*
* Creates a test that makes sure that when using a marker without a property
* that can establish a strict total order over a set of VMs, the proper error
* is sent.
*/
function createNoStrictTotalOrderKeyInMarkerTest(sortKey, sortOrder, exports) {
var testName = 'list_vms_marker_' + sortKey + '_' + sortOrder +
'_no_strict_total_order_key';
exports[testName] = function (t) {
var TEST_MARKER = {};
TEST_MARKER[sortKey] = NON_STRICT_TOTAL_ORDER_SORT_KEYS[sortKey];
var expectedError = {
code: 'ValidationFailed',
message: 'Invalid Parameters',
errors: [ {
field: 'marker',
code: 'Invalid',
message: 'Invalid marker: ' + JSON.stringify(TEST_MARKER) +
'. A marker needs to have a uuid property from ' +
'which a strict total order can be established'
} ]
};
common.testListInvalidParams(client,
{marker: JSON.stringify(TEST_MARKER), sort: sortKey},
expectedError, t,
function testDone(err) {
t.done();
});
};
}
Object.keys(NON_STRICT_TOTAL_ORDER_SORT_KEYS).forEach(function (sortKey) {
createMarkerTests(sortKey, exports);
});
| richardkiene/sdc-vmapi | test/vms.marker.test.js | JavaScript | mpl-2.0 | 19,701 | [
30522,
1013,
1008,
1008,
2023,
3120,
3642,
2433,
2003,
3395,
2000,
1996,
3408,
1997,
1996,
9587,
5831,
4571,
2270,
1008,
6105,
1010,
1058,
1012,
1016,
1012,
1014,
1012,
2065,
1037,
6100,
1997,
1996,
6131,
2140,
2001,
2025,
5500,
2007,
202... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
package org.teapot.backend.model.meta;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import org.teapot.backend.model.BaseEntity;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Lob;
import javax.persistence.Table;
@Entity
@Table(name = "action")
@NoArgsConstructor
@AllArgsConstructor
public class TeapotAction extends BaseEntity {
@Column(nullable = false, unique = true, length = 32)
@Getter
@Setter
private String name;
@Getter
@Setter
private String usage;
@Lob
@Column(length = 512)
@Getter
@Setter
private String manual;
}
| teapot-org/teapot-backend | src/main/java/org/teapot/backend/model/meta/TeapotAction.java | Java | gpl-3.0 | 691 | [
30522,
7427,
8917,
1012,
5572,
11008,
1012,
2067,
10497,
1012,
2944,
1012,
18804,
1025,
12324,
8840,
13344,
2243,
1012,
25699,
10623,
9363,
23808,
6820,
16761,
1025,
12324,
8840,
13344,
2243,
1012,
2131,
3334,
1025,
12324,
8840,
13344,
2243,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
# NUCLEO-F072RB 开发板 BSP 说明
## 简介
本文档为刘恒为 NUCLEO-F072RB 开发板提供的 BSP (板级支持包) 说明。
主要内容如下:
- 开发板资源介绍
- BSP 快速上手
- 进阶使用方法
通过阅读快速上手章节开发者可以快速地上手该 BSP,将 RT-Thread 运行在开发板上。在进阶使用指南章节,将会介绍更多高级功能,帮助开发者利用 RT-Thread 驱动更多板载资源。
## 开发板介绍
NUCLEO-F072RB 是 ST 官方推出的开发板,搭载 STM32F072RBT6 芯片,基于 ARM Cortex-M0 内核,最高主频 48 MHz,具有丰富的板载资源,可以充分发挥 STM32F072RBT6 的芯片性能。
开发板外观如下图所示:

NUCLEO-F072RB 开发板常用 **板载资源** 如下:
- MCU:STM32F072RBT6,主频 48MHz,128KB FLASH ,16KB RAM
- 常用外设
- LED:3 个,USB communication (LD1), user LED (LD2), power LED (LD3) 。
- 按键:2 个,USER and RESET 。
- 常用接口:USB 转串口、Arduino Uno 和 ST morpho 两类扩展接口
- 调试接口:板载 ST-LINK/V2-1 调试器。
开发板更多详细信息请参考意法半导体[NUCLEO-F072RB](https://www.st.com/content/st_com/en/products/evaluation-tools/product-evaluation-tools/mcu-mpu-eval-tools/stm32-mcu-mpu-eval-tools/stm32-nucleo-boards/nucleo-f072rb.html)
## 外设支持
本 BSP 目前对外设的支持情况如下:
| **片上外设** | **支持情况** | **备注** |
| :------------ | :----------: | :-----------------------------------: |
| GPIO | 支持 | PA0, PA1... PH1 ---> PIN: 0, 1...63 |
| UART | 支持 | UART2 |
| LED | 支持 | LED2 |
## 使用说明
使用说明分为如下两个章节:
- 快速上手
本章节是为刚接触 RT-Thread 的新手准备的使用说明,遵循简单的步骤即可将 RT-Thread 操作系统运行在该开发板上,看到实验效果 。
- 进阶使用
本章节是为需要在 RT-Thread 操作系统上使用更多开发板资源的开发者准备的。通过使用 ENV 工具对 BSP 进行配置,可以开启更多板载资源,实现更多高级功能。
### 快速上手
本 BSP 为开发者提供 MDK4、MDK5 和 IAR 工程,并且支持 GCC 开发环境。下面以 MDK5 开发环境为例,介绍如何将系统运行起来。
#### 硬件连接
使用 Type-A to Mini-B 线连接开发板和 PC 供电,红色 LED LD3 (PWR) 和 LD1 (COM) 会点亮。
#### 编译下载
双击 project.uvprojx 文件,打开 MDK5 工程,编译并下载程序到开发板。
> 工程默认配置使用 ST-LINK 下载程序,点击下载按钮即可下载程序到开发板。
#### 运行结果
下载程序成功之后,系统会自动运行,观察开发板上 LED 的运行效果,红色 LD3 和 LD1 常亮、绿色 LD2 会周期性闪烁。
USB 虚拟 COM 端口默认连接串口 2,在终端工具里打开相应的串口(115200-8-1-N),复位设备后,可以看到 RT-Thread 的输出信息:
```
\ | /
- RT - Thread Operating System
/ | \ 4.0.2 build May 30 2019
2006 - 2019 Copyright by rt-thread team
msh >
```
### 进阶使用
此 BSP 默认只开启了 GPIO 和 串口 2 的功能,更多高级功能需要利用 env 工具对 BSP 进行配置,步骤如下:
1. 在 bsp 下打开 env 工具。
2. 输入`menuconfig`命令配置工程,配置好之后保存退出。
3. 输入`pkgs --update`命令更新软件包。
4. 输入`scons --target=mdk4/mdk5/iar` 命令重新生成工程。
本章节更多详细的介绍请参考 [STM32 系列 BSP 外设驱动使用教程](../docs/STM32系列BSP外设驱动使用教程.md)。
## 注意事项
## 联系人信息
维护人:
- [刘恒](https://github.com/lhxzui), 邮箱:<iuzxhl@qq.com> | armink/rt-thread | bsp/stm32/stm32f072-st-nucleo/README_zh.md | Markdown | apache-2.0 | 3,936 | [
30522,
1001,
16371,
14321,
2080,
1011,
1042,
2692,
2581,
2475,
15185,
100,
100,
100,
18667,
2361,
100,
1865,
1001,
1001,
100,
1759,
1876,
1861,
100,
100,
100,
100,
100,
16371,
14321,
2080,
1011,
1042,
2692,
2581,
2475,
15185,
100,
100,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
<?php
/**
* Magento
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@magento.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade Magento to newer
* versions in the future. If you wish to customize Magento for your
* needs please refer to http://www.magento.com for more information.
*
* @category Mage
* @package Mage_ImportExport
* @copyright Copyright (c) 2006-2016 X.commerce, Inc. and affiliates (http://www.magento.com)
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
*/
/**
* Import controller
*
* @category Mage
* @package Mage_ImportExport
* @author Magento Core Team <core@magentocommerce.com>
*/
class Mage_ImportExport_Adminhtml_ImportController extends Mage_Adminhtml_Controller_Action
{
/**
* Custom constructor.
*
* @return void
*/
protected function _construct()
{
// Define module dependent translate
$this->setUsedModuleName('Mage_ImportExport');
}
/**
* Initialize layout.
*
* @return Mage_ImportExport_Adminhtml_ImportController
*/
protected function _initAction()
{
$this->_title($this->__('Import/Export'))
->loadLayout()
->_setActiveMenu('system/importexport');
return $this;
}
/**
* Check access (in the ACL) for current user.
*
* @return bool
*/
protected function _isAllowed()
{
return Mage::getSingleton('admin/session')->isAllowed('system/convert/import');
}
/**
* Index action.
*
* @return void
*/
public function indexAction()
{
$maxUploadSize = Mage::helper('importexport')->getMaxUploadSize();
$this->_getSession()->addNotice(
$this->__('Total size of uploadable files must not exceed %s', $maxUploadSize)
);
$this->_initAction()
->_title($this->__('Import'))
->_addBreadcrumb($this->__('Import'), $this->__('Import'));
$this->renderLayout();
}
/**
* Start import process action.
*
* @return void
*/
public function startAction()
{
$data = $this->getRequest()->getPost();
if ($data) {
$this->loadLayout(false);
/** @var $resultBlock Mage_ImportExport_Block_Adminhtml_Import_Frame_Result */
$resultBlock = $this->getLayout()->getBlock('import.frame.result');
/** @var $importModel Mage_ImportExport_Model_Import */
$importModel = Mage::getModel('importexport/import');
try {
$importModel->importSource();
$importModel->invalidateIndex();
$resultBlock->addAction('show', 'import_validation_container')
->addAction('innerHTML', 'import_validation_container_header', $this->__('Status'));
} catch (Exception $e) {
$resultBlock->addError($e->getMessage());
$this->renderLayout();
return;
}
$resultBlock->addAction('hide', array('edit_form', 'upload_button', 'messages'))
->addSuccess($this->__('Import successfully done.'));
$this->renderLayout();
} else {
$this->_redirect('*/*/index');
}
}
/**
* Validate uploaded files action.
*
* @return void
*/
public function validateAction()
{
$data = $this->getRequest()->getPost();
if ($data) {
$this->loadLayout(false);
/** @var $resultBlock Mage_ImportExport_Block_Adminhtml_Import_Frame_Result */
$resultBlock = $this->getLayout()->getBlock('import.frame.result');
// common actions
$resultBlock->addAction('show', 'import_validation_container')
->addAction('clear', array(
Mage_ImportExport_Model_Import::FIELD_NAME_SOURCE_FILE,
Mage_ImportExport_Model_Import::FIELD_NAME_IMG_ARCHIVE_FILE)
);
try {
/** @var $import Mage_ImportExport_Model_Import */
$import = Mage::getModel('importexport/import');
$validationResult = $import->validateSource($import->setData($data)->uploadSource());
if (!$import->getProcessedRowsCount()) {
$resultBlock->addError($this->__('File does not contain data. Please upload another one'));
} else {
if (!$validationResult) {
if ($import->getProcessedRowsCount() == $import->getInvalidRowsCount()) {
$resultBlock->addNotice(
$this->__('File is totally invalid. Please fix errors and re-upload file')
);
} elseif ($import->getErrorsCount() >= $import->getErrorsLimit()) {
$resultBlock->addNotice(
$this->__('Errors limit (%d) reached. Please fix errors and re-upload file', $import->getErrorsLimit())
);
} else {
if ($import->isImportAllowed()) {
$resultBlock->addNotice(
$this->__('Please fix errors and re-upload file or simply press "Import" button to skip rows with errors'),
true
);
} else {
$resultBlock->addNotice(
$this->__('File is partially valid, but import is not possible'), false
);
}
}
// errors info
foreach ($import->getErrors() as $errorCode => $rows) {
$error = $errorCode . ' ' . $this->__('in rows:') . ' ' . implode(', ', $rows);
$resultBlock->addError($error);
}
} else {
if ($import->isImportAllowed()) {
$resultBlock->addSuccess(
$this->__('File is valid! To start import process press "Import" button'), true
);
} else {
$resultBlock->addError(
$this->__('File is valid, but import is not possible'), false
);
}
}
$resultBlock->addNotice($import->getNotices());
$resultBlock->addNotice($this->__('Checked rows: %d, checked entities: %d, invalid rows: %d, total errors: %d', $import->getProcessedRowsCount(), $import->getProcessedEntitiesCount(), $import->getInvalidRowsCount(), $import->getErrorsCount()));
}
} catch (Exception $e) {
$resultBlock->addNotice($this->__('Please fix errors and re-upload file'))
->addError($e->getMessage());
}
$this->renderLayout();
} elseif ($this->getRequest()->isPost() && empty($_FILES)) {
$this->loadLayout(false);
$resultBlock = $this->getLayout()->getBlock('import.frame.result');
$resultBlock->addError($this->__('File was not uploaded'));
$this->renderLayout();
} else {
$this->_getSession()->addError($this->__('Data is invalid or file is not uploaded'));
$this->_redirect('*/*/index');
}
}
}
| hansbonini/cloud9-magento | www/app/code/core/Mage/ImportExport/controllers/Adminhtml/ImportController.php | PHP | mit | 8,143 | [
30522,
1026,
1029,
25718,
1013,
1008,
1008,
1008,
17454,
13663,
1008,
1008,
5060,
1997,
6105,
1008,
1008,
2023,
3120,
5371,
2003,
3395,
2000,
1996,
2330,
4007,
6105,
1006,
9808,
2140,
1017,
1012,
1014,
1007,
1008,
2008,
2003,
24378,
2007,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
# -*- coding: utf-8 -*-
from south.utils import datetime_utils as datetime
from south.db import db
from south.v2 import SchemaMigration
from django.db import models
class Migration(SchemaMigration):
def forwards(self, orm):
# Adding field 'Idea.color'
db.add_column(u'brainstorming_idea', 'color',
self.gf('django.db.models.fields.CharField')(default='', max_length=100, blank=True),
keep_default=False)
def backwards(self, orm):
# Deleting field 'Idea.color'
db.delete_column(u'brainstorming_idea', 'color')
models = {
u'brainstorming.brainstorming': {
'Meta': {'ordering': "['-created']", 'object_name': 'Brainstorming'},
'created': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now', 'blank': 'True'}),
'creator_email': ('django.db.models.fields.EmailField', [], {'max_length': '75'}),
'creator_ip': ('django.db.models.fields.CharField', [], {'max_length': '100', 'blank': 'True'}),
'details': ('django.db.models.fields.TextField', [], {'blank': 'True'}),
'id': ('django.db.models.fields.SlugField', [], {'max_length': '50', 'primary_key': 'True'}),
'modified': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now', 'blank': 'True'}),
'question': ('django.db.models.fields.CharField', [], {'max_length': '200'})
},
u'brainstorming.brainstormingwatcher': {
'Meta': {'ordering': "['-created']", 'unique_together': "(('brainstorming', 'email'),)", 'object_name': 'BrainstormingWatcher'},
'brainstorming': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['brainstorming.Brainstorming']"}),
'created': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now', 'blank': 'True'}),
'email': ('django.db.models.fields.EmailField', [], {'max_length': '75'}),
u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'modified': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now', 'blank': 'True'})
},
u'brainstorming.emailverification': {
'Meta': {'ordering': "['-created']", 'object_name': 'EmailVerification'},
'created': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now', 'blank': 'True'}),
'email': ('django.db.models.fields.EmailField', [], {'max_length': '75'}),
'id': ('django.db.models.fields.SlugField', [], {'max_length': '50', 'primary_key': 'True'}),
'modified': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now', 'blank': 'True'})
},
u'brainstorming.idea': {
'Meta': {'ordering': "['-created']", 'object_name': 'Idea'},
'brainstorming': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['brainstorming.Brainstorming']"}),
'color': ('django.db.models.fields.CharField', [], {'max_length': '100', 'blank': 'True'}),
'created': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now', 'blank': 'True'}),
'creator_ip': ('django.db.models.fields.CharField', [], {'max_length': '100', 'blank': 'True'}),
'creator_name': ('django.db.models.fields.CharField', [], {'max_length': '200', 'blank': 'True'}),
u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'modified': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now', 'blank': 'True'}),
'ratings': ('django.db.models.fields.IntegerField', [], {'default': '0'}),
'text': ('django.db.models.fields.TextField', [], {}),
'title': ('django.db.models.fields.CharField', [], {'max_length': '200', 'blank': 'True'})
}
}
complete_apps = ['brainstorming'] | atizo/braindump | brainstorming/migrations/0005_auto__add_field_idea_color.py | Python | mit | 4,031 | [
30522,
1001,
1011,
1008,
1011,
16861,
1024,
21183,
2546,
1011,
1022,
1011,
1008,
1011,
2013,
2148,
1012,
21183,
12146,
12324,
3058,
7292,
1035,
21183,
12146,
2004,
3058,
7292,
2013,
2148,
1012,
16962,
12324,
16962,
2013,
2148,
1012,
1058,
2... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
/*******************************************************************************
MPhoto - Photo viewer for multi-touch devices
Copyright (C) 2010 Mihai Paslariu
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*******************************************************************************/
#include "ImageLoadQueue.h"
// synchronized against all other methods
ImageLoadItem ImageLoadQueue::pop ( void )
{
ImageLoadItem x;
_sem.acquire();
_mutex.lock();
x = QQueue<ImageLoadItem>::front();
QQueue<ImageLoadItem>::pop_front();
_mutex.unlock();
return x;
}
// synchronized against all other methods
ImageLoadItem ImageLoadQueue::popWithPriority ( void )
{
ImageLoadItem x;
_sem.acquire();
_mutex.lock();
QQueue<ImageLoadItem>::Iterator it;
QQueue<ImageLoadItem>::Iterator it_max;
int max_prio = -1;
for ( it = this->begin(); it != this->end(); it++ )
{
if ( it->priority > max_prio )
{
max_prio = it->priority;
it_max = it;
}
}
x = *it_max;
this->erase( it_max );
_mutex.unlock();
return x;
}
// synchronized only against pop
void ImageLoadQueue::push ( const ImageLoadItem &x )
{
_mutex.lock();
QQueue<ImageLoadItem>::push_back(x);
_sem.release();
_mutex.unlock();
}
// synchronized only against pop
QList<ImageLoadItem> ImageLoadQueue::clear( void )
{
QList<ImageLoadItem> cleared_items = QList<ImageLoadItem>();
while ( _sem.tryAcquire() )
{
ImageLoadItem x;
_mutex.lock();
x = QQueue<ImageLoadItem>::front();
QQueue<ImageLoadItem>::pop_front();
_mutex.unlock();
cleared_items.append( x );
}
return cleared_items;
}
void ImageLoadQueue::clearPriorities( void )
{
_mutex.lock();
QQueue<ImageLoadItem>::Iterator it;
for ( it = this->begin(); it != this->end(); it++ )
{
it->priority = 0;
}
_mutex.unlock();
}
void ImageLoadQueue::updatePriority( QImage ** dest, int priority )
{
_mutex.lock();
QQueue<ImageLoadItem>::Iterator it;
for ( it = this->begin(); it != this->end(); it++ )
{
if ( it->destination == dest )
it->priority = priority;
}
_mutex.unlock();
}
| miabrahams/MPhoto | dev/ImageLoadQueue.cpp | C++ | gpl-3.0 | 2,610 | [
30522,
1013,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
100... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
int a,b,c;
int main()
{
float a,b;
a = 7.5;
c = a;
if (c > 7.1)
{
int a,b;
a = c+3*(10/9);
b = a/2/2;
printf("%d",b);
}
printf("%g",a);
printf("%d",c);
}
| fmgb/ProcesamientoLenguajes | Practica5/fuentes/pr-correcto1.c | C | gpl-2.0 | 196 | [
30522,
20014,
1037,
1010,
1038,
1010,
1039,
1025,
20014,
2364,
1006,
1007,
1063,
14257,
1037,
1010,
1038,
1025,
1037,
1027,
1021,
1012,
1019,
1025,
1039,
1027,
1037,
1025,
2065,
1006,
1039,
1028,
1021,
1012,
1015,
1007,
1063,
20014,
1037,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
import classnames from 'classnames';
import PropTypes from 'prop-types';
import React from 'react';
class SidebarItem extends React.Component {
static propTypes = {
baseClassName: PropTypes.string,
children: PropTypes.node,
modifier: PropTypes.string,
};
static defaultProps = {
baseClassName: 'sidebar__item',
};
render() {
const classes = classnames(this.props.baseClassName, {
[`${this.props.baseClassName}--${this.props.modifier}`]: this.props.modifier,
});
return <div className={classes}>{this.props.children}</div>;
}
}
export default SidebarItem;
| jfurrow/flood | client/src/javascript/components/sidebar/SidebarItem.js | JavaScript | gpl-3.0 | 606 | [
30522,
12324,
2465,
18442,
2015,
2013,
1005,
2465,
18442,
2015,
1005,
1025,
12324,
17678,
13874,
2015,
2013,
1005,
17678,
1011,
4127,
1005,
1025,
12324,
10509,
2013,
1005,
10509,
1005,
1025,
2465,
2217,
25990,
18532,
8908,
10509,
1012,
6922,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
// Copyright John Maddock 2008.
// Use, modification and distribution are subject to the
// Boost Software License, Version 1.0. (See accompanying file
// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
//
# include <pch.hpp>
#ifndef BOOST_MATH_TR1_SOURCE
# define BOOST_MATH_TR1_SOURCE
#endif
#include <boost/math/tr1.hpp>
#include <boost/math/special_functions/next.hpp>
#include "c_policy.hpp"
namespace boost{ namespace math{ namespace tr1{
extern "C" long double BOOST_MATH_TR1_DECL boost_nexttowardl BOOST_PREVENT_MACRO_SUBSTITUTION(long double x, long double y) BOOST_MATH_C99_THROW_SPEC
{
return c_policies::nextafter BOOST_PREVENT_MACRO_SUBSTITUTION(x, y);
}
}}}
| flingone/frameworks_base_cmds_remoted | libs/boost/libs/math/src/tr1/nexttowardl.cpp | C++ | apache-2.0 | 727 | [
30522,
1013,
1013,
9385,
2198,
5506,
14647,
2263,
1012,
1013,
1013,
2224,
1010,
14080,
1998,
4353,
2024,
3395,
2000,
1996,
1013,
1013,
12992,
4007,
6105,
1010,
2544,
1015,
1012,
1014,
1012,
1006,
2156,
10860,
5371,
1013,
1013,
6105,
1035,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
/*
* The Plaid API
*
* The Plaid REST API. Please see https://plaid.com/docs/api for more details.
*
* API version: 2020-09-14_1.78.0
*/
// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
package plaid
import (
"encoding/json"
)
// WalletTransactionExecuteResponse WalletTransactionExecuteResponse defines the response schema for `/wallet/transaction/execute`
type WalletTransactionExecuteResponse struct {
// A unique ID identifying the transaction
TransactionId string `json:"transaction_id"`
Status WalletTransactionStatus `json:"status"`
// A unique identifier for the request, which can be used for troubleshooting. This identifier, like all Plaid identifiers, is case sensitive.
RequestId string `json:"request_id"`
AdditionalProperties map[string]interface{}
}
type _WalletTransactionExecuteResponse WalletTransactionExecuteResponse
// NewWalletTransactionExecuteResponse instantiates a new WalletTransactionExecuteResponse object
// This constructor will assign default values to properties that have it defined,
// and makes sure properties required by API are set, but the set of arguments
// will change when the set of required properties is changed
func NewWalletTransactionExecuteResponse(transactionId string, status WalletTransactionStatus, requestId string) *WalletTransactionExecuteResponse {
this := WalletTransactionExecuteResponse{}
this.TransactionId = transactionId
this.Status = status
this.RequestId = requestId
return &this
}
// NewWalletTransactionExecuteResponseWithDefaults instantiates a new WalletTransactionExecuteResponse object
// This constructor will only assign default values to properties that have it defined,
// but it doesn't guarantee that properties required by API are set
func NewWalletTransactionExecuteResponseWithDefaults() *WalletTransactionExecuteResponse {
this := WalletTransactionExecuteResponse{}
return &this
}
// GetTransactionId returns the TransactionId field value
func (o *WalletTransactionExecuteResponse) GetTransactionId() string {
if o == nil {
var ret string
return ret
}
return o.TransactionId
}
// GetTransactionIdOk returns a tuple with the TransactionId field value
// and a boolean to check if the value has been set.
func (o *WalletTransactionExecuteResponse) GetTransactionIdOk() (*string, bool) {
if o == nil {
return nil, false
}
return &o.TransactionId, true
}
// SetTransactionId sets field value
func (o *WalletTransactionExecuteResponse) SetTransactionId(v string) {
o.TransactionId = v
}
// GetStatus returns the Status field value
func (o *WalletTransactionExecuteResponse) GetStatus() WalletTransactionStatus {
if o == nil {
var ret WalletTransactionStatus
return ret
}
return o.Status
}
// GetStatusOk returns a tuple with the Status field value
// and a boolean to check if the value has been set.
func (o *WalletTransactionExecuteResponse) GetStatusOk() (*WalletTransactionStatus, bool) {
if o == nil {
return nil, false
}
return &o.Status, true
}
// SetStatus sets field value
func (o *WalletTransactionExecuteResponse) SetStatus(v WalletTransactionStatus) {
o.Status = v
}
// GetRequestId returns the RequestId field value
func (o *WalletTransactionExecuteResponse) GetRequestId() string {
if o == nil {
var ret string
return ret
}
return o.RequestId
}
// GetRequestIdOk returns a tuple with the RequestId field value
// and a boolean to check if the value has been set.
func (o *WalletTransactionExecuteResponse) GetRequestIdOk() (*string, bool) {
if o == nil {
return nil, false
}
return &o.RequestId, true
}
// SetRequestId sets field value
func (o *WalletTransactionExecuteResponse) SetRequestId(v string) {
o.RequestId = v
}
func (o WalletTransactionExecuteResponse) MarshalJSON() ([]byte, error) {
toSerialize := map[string]interface{}{}
if true {
toSerialize["transaction_id"] = o.TransactionId
}
if true {
toSerialize["status"] = o.Status
}
if true {
toSerialize["request_id"] = o.RequestId
}
for key, value := range o.AdditionalProperties {
toSerialize[key] = value
}
return json.Marshal(toSerialize)
}
func (o *WalletTransactionExecuteResponse) UnmarshalJSON(bytes []byte) (err error) {
varWalletTransactionExecuteResponse := _WalletTransactionExecuteResponse{}
if err = json.Unmarshal(bytes, &varWalletTransactionExecuteResponse); err == nil {
*o = WalletTransactionExecuteResponse(varWalletTransactionExecuteResponse)
}
additionalProperties := make(map[string]interface{})
if err = json.Unmarshal(bytes, &additionalProperties); err == nil {
delete(additionalProperties, "transaction_id")
delete(additionalProperties, "status")
delete(additionalProperties, "request_id")
o.AdditionalProperties = additionalProperties
}
return err
}
type NullableWalletTransactionExecuteResponse struct {
value *WalletTransactionExecuteResponse
isSet bool
}
func (v NullableWalletTransactionExecuteResponse) Get() *WalletTransactionExecuteResponse {
return v.value
}
func (v *NullableWalletTransactionExecuteResponse) Set(val *WalletTransactionExecuteResponse) {
v.value = val
v.isSet = true
}
func (v NullableWalletTransactionExecuteResponse) IsSet() bool {
return v.isSet
}
func (v *NullableWalletTransactionExecuteResponse) Unset() {
v.value = nil
v.isSet = false
}
func NewNullableWalletTransactionExecuteResponse(val *WalletTransactionExecuteResponse) *NullableWalletTransactionExecuteResponse {
return &NullableWalletTransactionExecuteResponse{value: val, isSet: true}
}
func (v NullableWalletTransactionExecuteResponse) MarshalJSON() ([]byte, error) {
return json.Marshal(v.value)
}
func (v *NullableWalletTransactionExecuteResponse) UnmarshalJSON(src []byte) error {
v.isSet = true
return json.Unmarshal(src, &v.value)
}
| plaid/plaid-go | plaid/model_wallet_transaction_execute_response.go | GO | mit | 5,790 | [
30522,
1013,
1008,
1008,
1996,
26488,
17928,
1008,
1008,
1996,
26488,
2717,
17928,
1012,
3531,
2156,
16770,
1024,
1013,
1013,
26488,
1012,
4012,
1013,
9986,
2015,
1013,
17928,
2005,
2062,
4751,
1012,
1008,
1008,
17928,
2544,
1024,
12609,
10... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
# Fast-convolution via overlap-save: a partial drop-in replacement for scipy.signal.fftconvolve
Original repo: https://github.com/fasiha/overlap_save-py
**Changelog**
*1.1.2* support for numpy<1.15 (where numpy.flip had more limited behavior)—thanks again Matteo!
*1.1.1* full complex support (thanks Matteo Bachetti! [!1](https://github.com/fasiha/overlap_save-py/pull/1) & [!2](https://github.com/fasiha/overlap_save-py/pull/2))
*1.1.0* PyFFTW and `mirror` mode added | StingraySoftware/stingray | stingray/pulse/overlapandsave/README.md | Markdown | mit | 476 | [
30522,
1001,
3435,
1011,
9530,
6767,
7630,
3508,
3081,
17702,
1011,
3828,
1024,
1037,
7704,
4530,
1011,
1999,
6110,
2005,
16596,
7685,
1012,
4742,
1012,
21461,
13535,
2239,
6767,
2140,
3726,
2434,
16360,
2080,
1024,
16770,
1024,
1013,
1013,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
# Exemplo: "Feliz Natal" em Esperanto: Gajan Kristnaskon
$ zznatal #→ --regex ^"Feliz Natal" em .+: .+$
| gmgall/funcoeszz | testador/zznatal.sh | Shell | gpl-2.0 | 108 | [
30522,
1001,
4654,
6633,
24759,
2080,
1024,
1000,
10768,
3669,
2480,
17489,
1000,
7861,
9686,
4842,
21634,
1024,
11721,
8405,
19031,
2102,
11649,
19648,
1002,
1062,
2480,
19833,
2389,
1001,
1585,
1011,
1011,
19723,
10288,
1034,
1000,
10768,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
+++
title = "Número 203- Año XIV"
date = "1983-12-01"
numero = "203"
artistas = ["Ozzy Osbourne", "Robert Plant", "Led Zeppelin", "David Lebón", "Kiss", "Robert Plant", "Gustavo Bazterrica", "Los Abuelos de la Nada", "U'S'Festival", "Alejandro Lerner", "Riff", "Charly García", "Miguel Mateos", "Zas", "Luis Alberto Spinetta", "Litto Nebbia"]
colaboradores= ["Daniel Osvaldo Ripoll", "Juan Manuel Cibeira", "Osvaldo Marzullo", "Daniel Lauría", "Oscar Botto", "Walter Martínez", "Marta Ferro", "José Ángel Wolfman"]
discos = ["Alpha/Asia", "Escondo Mis Ojos Al Sol/Nito Mestre", "Tic'Tic/Los Helicópteros", "Plumas Blancas/Kajagoogoo", "Rock De Una Noche De Verano/Miguel Ríos"]
poster1 = "Ozzy Osbourne"
+++
**Póster**: Ozzy Osbourne.
**Nota de tapa**: Robert Plant. Ahora el funeral de Led Zeppelin.
**Reportajes**: David Lebón. Kiss. Robert Plant.
**Entrevistas**: Gustavo Bazterrica (Los Abuelos de la Nada).
**Notas sobre**:
- El festival del año: la isla de la fantasía. El U'S'Festival.
**Secciones**:
- Informasa. Cartelera. Discos. Avisos Libres. Correo. Paren las Máquinas. Cosmos.
- En vivo: Alejandro Lerner en Gran Rex. Riff en Ferro. Charly García en Luna Park. Miguel Mateos Zas en Odeón. Luis Alberto Spinetta en Coliseo.
| carlospeix/revista-pelo | content/numeros/1983/203.md | Markdown | mit | 1,301 | [
30522,
1009,
1009,
1009,
2516,
1027,
1000,
16371,
5017,
2080,
18540,
1011,
2019,
2080,
15939,
1000,
3058,
1027,
1000,
3172,
1011,
2260,
1011,
5890,
1000,
16371,
5017,
2080,
1027,
1000,
18540,
1000,
3063,
3022,
1027,
1031,
1000,
11472,
9096,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Form;
use Symfony\Component\Form\Exception\InvalidArgumentException;
use Symfony\Component\Form\Exception\OutOfBoundsException;
use Symfony\Component\Form\Exception\BadMethodCallException;
use Symfony\Component\Validator\ConstraintViolation;
/**
* Iterates over the errors of a form.
*
* Optionally, this class supports recursive iteration. In order to iterate
* recursively, set the constructor argument $deep to true. Now each element
* returned by the iterator is either an instance of {@link FormError} or of
* {@link FormErrorIterator}, in case the errors belong to a sub-form.
*
* You can also wrap the iterator into a {@link \RecursiveIteratorIterator} to
* flatten the recursive structure into a flat list of errors.
*
* @author Bernhard Schussek <bschussek@gmail.com>
*/
class FormErrorIterator implements \RecursiveIterator, \SeekableIterator, \ArrayAccess, \Countable
{
/**
* The prefix used for indenting nested error messages.
*
* @var string
*/
const INDENTATION = ' ';
/**
* @var FormInterface
*/
private $form;
/**
* @var FormError[]|FormErrorIterator[]
*/
private $errors;
/**
* Creates a new iterator.
*
* @param FormInterface $form The erroneous form
* @param array $errors The form errors
*
* @throws InvalidArgumentException If the errors are invalid
*/
public function __construct(FormInterface $form, array $errors)
{
foreach ($errors as $error) {
if (!($error instanceof FormError || $error instanceof self)) {
throw new InvalidArgumentException(sprintf(
'The errors must be instances of '.
'"\Symfony\Component\Form\FormError" or "%s". Got: "%s".',
__CLASS__,
is_object($error) ? get_class($error) : gettype($error)
));
}
}
$this->form = $form;
$this->errors = $errors;
}
/**
* Returns all iterated error messages as string.
*
* @return string The iterated error messages
*/
public function __toString()
{
$string = '';
foreach ($this->errors as $error) {
if ($error instanceof FormError) {
$string .= 'ERROR: '.$error->getMessage()."\n";
} else {
/* @var $error FormErrorIterator */
$string .= $error->form->getName().":\n";
$string .= self::indent((string) $error);
}
}
return $string;
}
/**
* Returns the iterated form.
*
* @return FormInterface The form whose errors are iterated by this object
*/
public function getForm()
{
return $this->form;
}
/**
* Returns the current element of the iterator.
*
* @return FormError|FormErrorIterator an error or an iterator containing
* nested errors
*/
public function current()
{
return current($this->errors);
}
/**
* Advances the iterator to the next position.
*/
public function next()
{
next($this->errors);
}
/**
* Returns the current position of the iterator.
*
* @return int The 0-indexed position
*/
public function key()
{
return key($this->errors);
}
/**
* Returns whether the iterator's position is valid.
*
* @return bool Whether the iterator is valid
*/
public function valid()
{
return null !== key($this->errors);
}
/**
* Sets the iterator's position to the beginning.
*
* This method detects if errors have been added to the form since the
* construction of the iterator.
*/
public function rewind()
{
reset($this->errors);
}
/**
* Returns whether a position exists in the iterator.
*
* @param int $position The position
*
* @return bool Whether that position exists
*/
public function offsetExists($position)
{
return isset($this->errors[$position]);
}
/**
* Returns the element at a position in the iterator.
*
* @param int $position The position
*
* @return FormError|FormErrorIterator The element at the given position
*
* @throws OutOfBoundsException If the given position does not exist
*/
public function offsetGet($position)
{
if (!isset($this->errors[$position])) {
throw new OutOfBoundsException('The offset '.$position.' does not exist.');
}
return $this->errors[$position];
}
/**
* Unsupported method.
*
* @throws BadMethodCallException
*/
public function offsetSet($position, $value)
{
throw new BadMethodCallException('The iterator doesn\'t support modification of elements.');
}
/**
* Unsupported method.
*
* @throws BadMethodCallException
*/
public function offsetUnset($position)
{
throw new BadMethodCallException('The iterator doesn\'t support modification of elements.');
}
/**
* Returns whether the current element of the iterator can be recursed
* into.
*
* @return bool Whether the current element is an instance of this class
*/
public function hasChildren()
{
return current($this->errors) instanceof self;
}
/**
* Alias of {@link current()}.
*/
public function getChildren()
{
return current($this->errors);
}
/**
* Returns the number of elements in the iterator.
*
* Note that this is not the total number of errors, if the constructor
* parameter $deep was set to true! In that case, you should wrap the
* iterator into a {@link \RecursiveIteratorIterator} with the standard mode
* {@link \RecursiveIteratorIterator::LEAVES_ONLY} and count the result.
*
* $iterator = new \RecursiveIteratorIterator($form->getErrors(true));
* $count = count(iterator_to_array($iterator));
*
* Alternatively, set the constructor argument $flatten to true as well.
*
* $count = count($form->getErrors(true, true));
*
* @return int The number of iterated elements
*/
public function count()
{
return count($this->errors);
}
/**
* Sets the position of the iterator.
*
* @param int $position The new position
*
* @throws OutOfBoundsException If the position is invalid
*/
public function seek($position)
{
if (!isset($this->errors[$position])) {
throw new OutOfBoundsException('The offset '.$position.' does not exist.');
}
reset($this->errors);
while ($position !== key($this->errors)) {
next($this->errors);
}
}
/**
* Creates iterator for errors with specific codes.
*
* @param string|string[] $codes The codes to find
*
* @return static new instance which contains only specific errors
*/
public function findByCodes($codes)
{
$codes = (array) $codes;
$errors = array();
foreach ($this as $error) {
$cause = $error->getCause();
if ($cause instanceof ConstraintViolation && in_array($cause->getCode(), $codes, true)) {
$errors[] = $error;
}
}
return new static($this->form, $errors);
}
/**
* Utility function for indenting multi-line strings.
*
* @param string $string The string
*
* @return string The indented string
*/
private static function indent($string)
{
return rtrim(self::INDENTATION.str_replace("\n", "\n".self::INDENTATION, $string), ' ');
}
}
| UrbanLion/developmentpricing | vendor/symfony/symfony/src/Symfony/Component/Form/FormErrorIterator.php | PHP | mit | 8,157 | [
30522,
1026,
1029,
25718,
1013,
1008,
1008,
2023,
5371,
2003,
2112,
1997,
1996,
25353,
2213,
14876,
4890,
7427,
1012,
1008,
1008,
1006,
1039,
1007,
6904,
11283,
2078,
8962,
2368,
19562,
1026,
6904,
11283,
2078,
1030,
25353,
2213,
14876,
489... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
/*
* Support functions
*
* Copyright (c) 2010-2013, Joachim Metz <joachim.metz@gmail.com>
*
* Refer to AUTHORS for acknowledgements.
*
* This software is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this software. If not, see <http://www.gnu.org/licenses/>.
*/
#if !defined( _LIBFCACHE_SUPPORT_H )
#define _LIBFCACHE_SUPPORT_H
#include <common.h>
#include <types.h>
#include "libfcache_extern.h"
#if defined( __cplusplus )
extern "C" {
#endif
#if !defined( HAVE_LOCAL_LIBFCACHE )
LIBFCACHE_EXTERN \
const char *libfcache_get_version(
void );
#endif /* !defined( HAVE_LOCAL_LIBFCACHE ) */
#if defined( __cplusplus )
}
#endif
#endif
| sleuthkit/libewf_64bit | libfcache/libfcache_support.h | C | lgpl-3.0 | 1,201 | [
30522,
1013,
1008,
1008,
2490,
4972,
1008,
1008,
9385,
1006,
1039,
1007,
2230,
1011,
2286,
1010,
17286,
24424,
1026,
17286,
1012,
24424,
1030,
20917,
4014,
1012,
4012,
1028,
1008,
1008,
6523,
2000,
6048,
2005,
13399,
8163,
1012,
1008,
1008,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
/***************************************************************************
*
Copyright 2013 CertiVox UK Ltd. *
*
This file is part of CertiVox MIRACL Crypto SDK. *
*
The CertiVox MIRACL Crypto SDK provides developers with an *
extensive and efficient set of cryptographic functions. *
For further information about its features and functionalities please *
refer to http://www.certivox.com *
*
* The CertiVox MIRACL Crypto SDK is free software: you can *
redistribute it and/or modify it under the terms of the *
GNU Affero General Public License as published by the *
Free Software Foundation, either version 3 of the License, *
or (at your option) any later version. *
*
* The CertiVox MIRACL Crypto SDK is distributed in the hope *
that it will be useful, but WITHOUT ANY WARRANTY; without even the *
implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
See the GNU Affero General Public License for more details. *
*
* You should have received a copy of the GNU Affero General Public *
License along with CertiVox MIRACL Crypto SDK. *
If not, see <http://www.gnu.org/licenses/>. *
*
You can be released from the requirements of the license by purchasing *
a commercial license. Buying such a license is mandatory as soon as you *
develop commercial activities involving the CertiVox MIRACL Crypto SDK *
without disclosing the source code of your own applications, or shipping *
the CertiVox MIRACL Crypto SDK with a closed source product. *
*
***************************************************************************/
/*
*
* MIRACL C++ Header file big.h
*
* AUTHOR : N.Coghlan
* Modified by M.Scott
*
* PURPOSE : Definition of class Big
*
* Bigs are normally created on the heap, but by defining BIGS=m
* on the compiler command line, Bigs are instead mostly created from the
* stack. Note that m must be same or less than the n in the main program
* with for example
*
* Miracl precison(n,0);
*
* where n is the (fixed) size in words of each Big.
*
* This may be faster, as C++ tends to create and destroy lots of
* temporaries. Especially recommended if m is small. Do not use
* for program development
*
* However Bigs created from a string are always allocated from the heap.
* This is useful for creating large read-only constants which are larger
* than m.
*
* NOTE:- I/O conversion
*
* To convert a hex character string to a Big
*
* Big x;
* char c[100];
*
* mip->IOBASE=16;
* x=c;
*
* To convert a Big to a hex character string
*
* mip->IOBASE=16;
* c << x;
*
* To convert to/from pure binary, see the from_binary()
* and to_binary() friend functions.
*
* int len;
* char c[100];
* ...
* Big x=from_binary(len,c); // creates Big x from len bytes of binary in c
*
* len=to_binary(x,100,c,FALSE); // converts Big x to len bytes binary in c[100]
* len=to_binary(x,100,c,TRUE); // converts Big x to len bytes binary in c[100]
* // (right justified with leading zeros)
*/
#ifndef BIG_H
#define BIG_H
#include <cstdlib>
//#include <cmath>
#include <cstdio>
#include "mirdef.h"
#ifdef MR_CPP
#include "miracl.h"
#else
extern "C"
{
#include "miracl.h"
}
#endif
#ifndef MR_NO_STANDARD_IO
#include <iostream>
using std::istream;
using std::ostream;
#endif
#ifndef MIRACL_CLASS
#define MIRACL_CLASS
#ifdef __cplusplus
#ifdef MR_GENERIC_MT
#error "The generic method isn't supported for C++, its C only"
#endif
#endif
class Miracl
{ /* dummy class to initialise MIRACL - MUST be called before any Bigs *
* are created. This could be a problem for static/global data declared *
* in modules other than the main module */
miracl *mr;
public:
Miracl(int nd,mr_small nb=0)
{mr=mirsys(nd,nb);
#ifdef MR_FLASH
mr->RPOINT=TRUE;
#endif
}
miracl *operator&() {return mr;}
~Miracl() {mirexit();}
};
#endif
/*
#ifdef BIGS
#define MR_INIT_BIG memset(mem,0,mr_big_reserve(1,BIGS)); fn=(big)mirvar_mem_variable(mem,0,BIGS);
#else
#define MR_INIT_BIG mem=(char *)memalloc(1); fn=(big)mirvar_mem(mem,0);
#endif
*/
#ifdef BIGS
#define MR_INIT_BIG fn=&b; b.w=a; b.len=0; for (int i=0;i<BIGS;i++) a[i]=0;
#else
#define MR_INIT_BIG fn=mirvar(0);
#endif
class Big
{
big fn;
/*
#ifdef BIGS
char mem[mr_big_reserve(1,BIGS)];
#else
char *mem;
#endif
*/
#ifdef BIGS
mr_small a[BIGS];
bigtype b;
#endif
public:
Big() {MR_INIT_BIG }
Big(int j) {MR_INIT_BIG convert(j,fn); }
Big(unsigned int j) {MR_INIT_BIG uconvert(j,fn); }
Big(long lg) {MR_INIT_BIG lgconv(lg,fn);}
Big(unsigned long lg) {MR_INIT_BIG ulgconv(lg,fn);}
#ifdef MR_UTYPE_NOT_INT_OR_LONG
Big(mr_utype ut) {MR_INIT_BIG tconvert(ut,fn);}
#endif
#ifdef mr_dltype
#ifndef MR_DLTYPE_IS_INT
#ifndef MR_DLTYPE_IS_LONG
Big(mr_dltype dl) {MR_INIT_BIG dlconv(dl,fn);}
#endif
#endif
#endif
#ifndef MR_SIMPLE_IO
#ifdef MR_SIMPLE_BASE
Big(char* s) {MR_INIT_BIG instr(fn,s);}
#else
Big(char* s) {MR_INIT_BIG cinstr(fn,s);}
#endif
#endif
Big(big& c) {MR_INIT_BIG copy(c,fn);}
Big(const Big& c) {MR_INIT_BIG copy(c.fn,fn);}
Big(big* c) { fn=*c; }
Big& operator=(int i) {convert(i,fn); return *this;}
Big& operator=(long lg){lgconv(lg,fn); return *this;}
#ifdef MR_UTYPE_NOT_INT_OR_LONG
Big& operator=(mr_utype ut){tconvert(ut,fn); return *this;}
#endif
#ifdef mr_dltype
#ifndef MR_DLTYPE_IS_INT
#ifndef MR_DLTYPE_IS_LONG
Big& operator=(mr_dltype dl){dlconv(dl,fn); return *this;}
#endif
#endif
#endif
Big& operator=(mr_small s) {fn->len=1; fn->w[0]=s; return *this;}
Big& operator=(const Big& b) {copy(b.fn,fn); return *this;}
Big& operator=(big& b) {copy(b,fn); return *this;}
Big& operator=(big* b) {fn=*b; return *this;}
#ifndef MR_SIMPLE_IO
#ifdef MR_SIMPLE_BASE
Big& operator=(char* s){instr(fn,s);return *this;}
#else
Big& operator=(char* s){cinstr(fn,s);return *this;}
#endif
#endif
Big& operator++() {incr(fn,1,fn); return *this;}
Big& operator--() {decr(fn,1,fn); return *this;}
Big& operator+=(int i) {incr(fn,i,fn); return *this;}
Big& operator+=(const Big& b){add(fn,b.fn,fn); return *this;}
Big& operator-=(int i) {decr(fn,i,fn); return *this;}
Big& operator-=(const Big& b) {subtract(fn,b.fn,fn); return *this;}
Big& operator*=(int i) {premult(fn,i,fn); return *this;}
Big& operator*=(const Big& b) {multiply(fn,b.fn,fn); return *this;}
Big& operator/=(int i) {subdiv(fn,i,fn); return *this;}
Big& operator/=(const Big& b) {divide(fn,b.fn,fn); return *this;}
Big& operator%=(int i) {convert(subdiv(fn,i,fn),fn); return *this;}
Big& operator%=(const Big& b) {divide(fn,b.fn,b.fn); return *this;}
Big& operator<<=(int i) {sftbit(fn,i,fn); return *this;}
Big& operator>>=(int i) {sftbit(fn,-i,fn); return *this;}
Big& shift(int n) {mr_shift(fn,n,fn); return *this;}
mr_small& operator[](int i) {return fn->w[i];}
void negate() const;
BOOL iszero() const;
BOOL isone() const;
int get(int index) { int m; m=getdig(fn,index); return m; }
void set(int index,int n) { putdig(n,fn,index);}
int len() const;
big getbig() const;
friend class Flash;
friend Big operator-(const Big&);
friend Big operator+(const Big&,int);
friend Big operator+(int,const Big&);
friend Big operator+(const Big&,const Big&);
friend Big operator-(const Big&, int);
friend Big operator-(int,const Big&);
friend Big operator-(const Big&,const Big&);
friend Big operator*(const Big&, int);
friend Big operator*(int,const Big&);
friend Big operator*(const Big&,const Big&);
friend BOOL fmt(int n,const Big&,const Big&,Big&); // fast mult - top half
friend Big operator/(const Big&,int);
friend Big operator/(const Big&,const Big&);
friend int operator%(const Big&, int);
friend Big operator%(const Big&, const Big&);
friend Big operator<<(const Big&, int);
friend Big operator>>(const Big&, int);
friend BOOL operator<=(const Big& b1,const Big& b2)
{if (mr_compare(b1.fn,b2.fn)<=0) return TRUE; else return FALSE;}
friend BOOL operator>=(const Big& b1,const Big& b2)
{if (mr_compare(b1.fn,b2.fn)>=0) return TRUE; else return FALSE;}
friend BOOL operator==(const Big& b1,const Big& b2)
{if (mr_compare(b1.fn,b2.fn)==0) return TRUE; else return FALSE;}
friend BOOL operator!=(const Big& b1,const Big& b2)
{if (mr_compare(b1.fn,b2.fn)!=0) return TRUE; else return FALSE;}
friend BOOL operator<(const Big& b1,const Big& b2)
{if (mr_compare(b1.fn,b2.fn)<0) return TRUE; else return FALSE;}
friend BOOL operator>(const Big& b1,const Big& b2)
{if (mr_compare(b1.fn,b2.fn)>0) return TRUE; else return FALSE;}
friend Big from_binary(int,char *);
friend int to_binary(const Big&,int,char *,BOOL justify=FALSE);
friend Big modmult(const Big&,const Big&,const Big&);
friend Big mad(const Big&,const Big&,const Big&,const Big&,Big&);
friend Big norm(const Big&);
friend Big sqrt(const Big&);
friend Big root(const Big&,int);
friend Big gcd(const Big&,const Big&);
friend void set_zzn3(int cnr,Big& sru) {get_mip()->cnr=cnr; nres(sru.fn,get_mip()->sru);}
friend int recode(const Big& e,int t,int w,int i) {return recode(e.fn,t,w,i);}
#ifndef MR_FP
friend Big land(const Big&,const Big&); // logical AND
friend Big lxor(const Big&,const Big&); // logical XOR
#endif
friend Big pow(const Big&,int); // x^m
friend Big pow(const Big&, int, const Big&); // x^m mod n
friend Big pow(int, const Big&, const Big&); // x^m mod n
friend Big pow(const Big&, const Big&, const Big&); // x^m mod n
friend Big pow(const Big&, const Big&, const Big&, const Big&, const Big&);
// x^m.y^k mod n
friend Big pow(int,Big *,Big *,Big); // x[0]^m[0].x[1].m[1]... mod n
friend Big luc(const Big& ,const Big&, const Big&, Big *b4=NULL);
friend Big moddiv(const Big&,const Big&,const Big&);
friend Big inverse(const Big&, const Big&);
friend void multi_inverse(int,Big*,const Big&,Big *);
#ifndef MR_NO_RAND
friend Big rand(const Big&); // 0 < rand < parameter
friend Big rand(int,int); // (digits,base) e.g. (32,16)
friend Big randbits(int); // n random bits
friend Big strong_rand(csprng *,const Big&);
friend Big strong_rand(csprng *,int,int);
#endif
friend Big abs(const Big&);
// This next only works if MIRACL is using a binary base...
friend int bit(const Big& b,int i) {return mr_testbit(b.fn,i);}
friend int bits(const Big& b) {return logb2(b.fn);}
friend int ham(const Big& b) {return hamming(b.fn);}
friend int jacobi(const Big& b1,const Big& b2) {return jack(b1.fn,b2.fn);}
friend int toint(const Big& b) {return size(b.fn);}
friend BOOL prime(const Big& b) {return isprime(b.fn);}
friend Big nextprime(const Big&);
friend Big nextsafeprime(int type,int subset,const Big&);
friend Big trial_divide(const Big& b);
friend BOOL small_factors(const Big& b);
friend BOOL perfect_power(const Big& b);
friend Big sqrt(const Big&,const Big&);
friend void ecurve(const Big&,const Big&,const Big&,int);
friend BOOL ecurve2(int,int,int,int,const Big&,const Big&,BOOL,int);
friend BOOL is_on_curve(const Big&);
friend void modulo(const Big&);
friend BOOL modulo(int,int,int,int,BOOL);
friend Big get_modulus(void);
friend int window(const Big&,int,int*,int*,int window_size=5);
friend int naf_window(const Big&,const Big&,int,int*,int*,int store=11);
friend void jsf(const Big&,const Big&,Big&,Big&,Big&,Big&);
/* Montgomery stuff */
friend Big nres(const Big&);
friend Big redc(const Big&);
/*
friend Big nres_negate(const Big&);
friend Big nres_modmult(const Big&,const Big&);
friend Big nres_premult(const Big&,int);
friend Big nres_pow(const Big&,const Big&);
friend Big nres_pow2(const Big&,const Big&,const Big&,const Big&);
friend Big nres_pown(int,Big *,Big *);
friend Big nres_luc(const Big&,const Big&,Big *b3=NULL);
friend Big nres_sqrt(const Big&);
friend Big nres_modadd(const Big&,const Big&);
friend Big nres_modsub(const Big&,const Big&);
friend Big nres_moddiv(const Big&,const Big&);
*/
/* these are faster.... */
/*
friend void nres_modmult(Big& a,const Big& b,Big& c)
{nres_modmult(a.fn,b.fn,c.fn);}
friend void nres_modadd(Big& a,const Big& b,Big& c)
{nres_modadd(a.fn,b.fn,c.fn);}
friend void nres_modsub(Big& a,const Big& b,Big& c)
{nres_modsub(a.fn,b.fn,c.fn);}
friend void nres_negate(Big& a,Big& b)
{nres_negate(a.fn,b.fn);}
friend void nres_premult(Big& a,int b,Big& c)
{nres_premult(a.fn,b,c.fn);}
friend void nres_moddiv(Big & a,const Big& b,Big& c)
{nres_moddiv(a.fn,b.fn,c.fn);}
*/
friend Big shift(const Big&b,int n);
friend int length(const Big&b);
/* Note that when inputting text as a number the CR is NOT *
* included in the text, unlike C I/O which does include CR. */
#ifndef MR_NO_STANDARD_IO
friend istream& operator>>(istream&, Big&);
friend ostream& operator<<(ostream&, const Big&);
friend ostream& otfloat(ostream&,const Big&,int);
#endif
// output Big to a String
friend char * operator<<(char * s,const Big&);
~Big() {
// zero(fn);
#ifndef BIGS
mr_free(fn);
#endif
}
};
extern BOOL modulo(int,int,int,int,BOOL);
extern Big get_modulus(void);
extern Big rand(int,int);
extern Big strong_rand(csprng *,int,int);
extern Big from_binary(int,char *);
extern int to_binary(const Big&,int,char *,BOOL);
using namespace std;
#endif
| GaloisInc/hacrypto | src/C++/MIRACL/MIRACL-4.0/include/big.h | C | bsd-3-clause | 15,058 | [
30522,
1013,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
100... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
jsonp({"cep":"61600180","logradouro":"Rua Bar\u00e3o de Ibiapaba","bairro":"Centro","cidade":"Caucaia","uf":"CE","estado":"Cear\u00e1"});
| lfreneda/cepdb | api/v1/61600180.jsonp.js | JavaScript | cc0-1.0 | 138 | [
30522,
1046,
3385,
2361,
1006,
1063,
1000,
8292,
2361,
1000,
1024,
1000,
6079,
16086,
24096,
17914,
1000,
1010,
1000,
8833,
12173,
8162,
2080,
1000,
1024,
1000,
21766,
2050,
3347,
1032,
1057,
8889,
2063,
2509,
2080,
2139,
21307,
2401,
4502,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
{-# LANGUAGE DeriveFunctor #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE TupleSections #-}
{- |
Module : Network.MPD.Applicative.Internal
Copyright : (c) Simon Hengel 2012
License : MIT
Maintainer : joachifm@fastmail.fm
Stability : stable
Portability : unportable
Applicative MPD command interface.
This allows us to combine commands into command lists, as in
> (,,) <$> currentSong <*> stats <*> status
where the requests are automatically combined into a command list and
the result of each command passed to the consumer.
-}
module Network.MPD.Applicative.Internal
( Parser(..)
, liftParser
, getResponse
, emptyResponse
, unexpected
, Command(..)
, runCommand
) where
import Control.Monad
import Data.ByteString.Char8 (ByteString)
import Network.MPD.Core hiding (getResponse)
import qualified Network.MPD.Core as Core
import Control.Monad.Except
import qualified Control.Monad.Fail as Fail
-- | A line-oriented parser that returns a value along with any remaining input.
newtype Parser a
= Parser { runParser :: [ByteString] -> Either String (a, [ByteString]) }
deriving Functor
instance Monad Parser where
return a = Parser $ \input -> Right (a, input)
p1 >>= p2 = Parser $ \input -> runParser p1 input >>= uncurry (runParser . p2)
instance Fail.MonadFail Parser where
fail = Prelude.fail
instance Applicative Parser where
pure = return
(<*>) = ap
-- | Convert a regular parser.
liftParser :: ([ByteString] -> Either String a) -> Parser a
liftParser p = Parser $ \input -> case break (== "list_OK") input of
(xs, ys) -> fmap (, drop 1 ys) (p xs)
-- | Return everything until the next "list_OK".
getResponse :: Parser [ByteString]
getResponse = Parser $ \input -> case break (== "list_OK") input of
(xs, ys) -> Right (xs, drop 1 ys)
-- | For commands returning an empty response.
emptyResponse :: Parser ()
emptyResponse = do
r <- getResponse
unless (null r) $
unexpected r
-- | Fail with unexpected response.
unexpected :: [ByteString] -> Parser a
unexpected = fail . ("unexpected Response: " ++) . show
-- | A compound command, comprising a parser for the responses and a
-- combined request of an arbitrary number of commands.
data Command a = Command {
commandParser :: Parser a
, commandRequest :: [String]
} deriving Functor
instance Applicative Command where
pure a = Command (pure a) []
(Command p1 c1) <*> (Command p2 c2) = Command (p1 <*> p2) (c1 ++ c2)
-- | Execute a 'Command'.
runCommand :: MonadMPD m => Command a -> m a
runCommand (Command p c) = do
r <- Core.getResponse command
case runParser p r of
Left err -> throwError (Unexpected err)
Right (a, []) -> return a
Right (_, xs) -> throwError (Unexpected $ "superfluous input: " ++ show xs)
where
command = case c of
[x] -> x
xs -> unlines ("command_list_ok_begin" : xs)
++ "command_list_end"
| bens/libmpd-haskell | src/Network/MPD/Applicative/Internal.hs | Haskell | lgpl-2.1 | 3,046 | [
30522,
1063,
1011,
1001,
2653,
18547,
11263,
12273,
4263,
1001,
1011,
1065,
1063,
1011,
1001,
2653,
2058,
17468,
3367,
4892,
2015,
1001,
1011,
1065,
1063,
1011,
1001,
2653,
10722,
21112,
18491,
2015,
1001,
1011,
1065,
1063,
1011,
1064,
1133... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
require 'cases/helper'
require 'support/schema_dumping_helper'
if ActiveRecord::Base.connection.supports_datetime_with_precision?
class DateTimePrecisionTest < ActiveRecord::TestCase
include SchemaDumpingHelper
self.use_transactional_tests = false
class Foo < ActiveRecord::Base; end
setup do
@connection = ActiveRecord::Base.connection
Foo.reset_column_information
end
teardown do
@connection.drop_table :foos, if_exists: true
end
def test_datetime_data_type_with_precision
@connection.create_table(:foos, force: true)
@connection.add_column :foos, :created_at, :datetime, precision: 0
@connection.add_column :foos, :updated_at, :datetime, precision: 5
assert_equal 0, Foo.columns_hash['created_at'].precision
assert_equal 5, Foo.columns_hash['updated_at'].precision
end
def test_timestamps_helper_with_custom_precision
@connection.create_table(:foos, force: true) do |t|
t.timestamps precision: 4
end
assert_equal 4, Foo.columns_hash['created_at'].precision
assert_equal 4, Foo.columns_hash['updated_at'].precision
end
def test_passing_precision_to_datetime_does_not_set_limit
@connection.create_table(:foos, force: true) do |t|
t.timestamps precision: 4
end
assert_nil Foo.columns_hash['created_at'].limit
assert_nil Foo.columns_hash['updated_at'].limit
end
def test_invalid_datetime_precision_raises_error
assert_raises ActiveRecord::ActiveRecordError do
@connection.create_table(:foos, force: true) do |t|
t.timestamps precision: 7
end
end
end
def test_formatting_datetime_according_to_precision
@connection.create_table(:foos, force: true) do |t|
t.datetime :created_at, precision: 0
t.datetime :updated_at, precision: 4
end
date = ::Time.utc(2014, 8, 17, 12, 30, 0, 999999)
Foo.create!(created_at: date, updated_at: date)
assert foo = Foo.find_by(created_at: date)
assert_equal 1, Foo.where(updated_at: date).count
assert_equal date.to_s, foo.created_at.to_s
assert_equal date.to_s, foo.updated_at.to_s
assert_equal 000000, foo.created_at.usec
assert_equal 999900, foo.updated_at.usec
end
def test_schema_dump_includes_datetime_precision
@connection.create_table(:foos, force: true) do |t|
t.timestamps precision: 6
end
output = dump_table_schema("foos")
assert_match %r{t\.datetime\s+"created_at",\s+precision: 6,\s+null: false$}, output
assert_match %r{t\.datetime\s+"updated_at",\s+precision: 6,\s+null: false$}, output
end
if current_adapter?(:PostgreSQLAdapter)
def test_datetime_precision_with_zero_should_be_dumped
@connection.create_table(:foos, force: true) do |t|
t.timestamps precision: 0
end
output = dump_table_schema("foos")
assert_match %r{t\.datetime\s+"created_at",\s+precision: 0,\s+null: false$}, output
assert_match %r{t\.datetime\s+"updated_at",\s+precision: 0,\s+null: false$}, output
end
end
end
end
| rokn/Count_Words_2015 | fetched_code/ruby/date_time_precision_test.rb | Ruby | mit | 3,012 | [
30522,
5478,
1005,
3572,
1013,
2393,
2121,
1005,
5478,
1005,
2490,
1013,
8040,
28433,
1035,
23642,
1035,
2393,
2121,
1005,
2065,
3161,
2890,
27108,
2094,
1024,
1024,
2918,
1012,
4434,
1012,
6753,
1035,
3058,
7292,
1035,
2007,
1035,
11718,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
/*
* Copyright (C) 2003, 2006, 2010, 2013 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
* THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef Language_h
#define Language_h
#include <wtf/Forward.h>
#include <wtf/Vector.h>
namespace WebCore {
WEBCORE_EXPORT String defaultLanguage();
WEBCORE_EXPORT Vector<String> userPreferredLanguages();
Vector<String> userPreferredLanguagesOverride();
WEBCORE_EXPORT void overrideUserPreferredLanguages(const Vector<String>&);
size_t indexOfBestMatchingLanguageInList(const String& language, const Vector<String>& languageList, bool& exactMatch);
// The observer function will be called when system language changes.
typedef void (*LanguageChangeObserverFunction)(void* context);
WEBCORE_EXPORT void addLanguageChangeObserver(void* context, LanguageChangeObserverFunction);
WEBCORE_EXPORT void removeLanguageChangeObserver(void* context);
Vector<String> platformUserPreferredLanguages();
String displayNameForLanguageLocale(const String&);
// Called from platform specific code when the user's preferred language(s) change.
WEBCORE_EXPORT void languageDidChange();
}
#endif
| teamfx/openjfx-9-dev-rt | modules/javafx.web/src/main/native/Source/WebCore/platform/Language.h | C | gpl-2.0 | 2,357 | [
30522,
1013,
1008,
1008,
9385,
1006,
1039,
1007,
2494,
1010,
2294,
1010,
2230,
1010,
2286,
6207,
4297,
1012,
2035,
2916,
9235,
1012,
1008,
1008,
25707,
1998,
2224,
1999,
3120,
1998,
12441,
3596,
1010,
2007,
2030,
2302,
1008,
14080,
1010,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<!-- NewPage -->
<html lang="it">
<head>
<!-- Generated by javadoc (version 1.7.0_12-ea) on Wed Jan 09 22:57:58 CET 2013 -->
<title>Uses of Class mk.tmdb.core.TMDbAuthentication</title>
<meta name="date" content="2013-01-09">
<link rel="stylesheet" type="text/css" href="../../../../stylesheet.css" title="Style">
</head>
<body>
<script type="text/javascript"><!--
if (location.href.indexOf('is-external=true') == -1) {
parent.document.title="Uses of Class mk.tmdb.core.TMDbAuthentication";
}
//-->
</script>
<noscript>
<div>JavaScript is disabled on your browser.</div>
</noscript>
<!-- ========= START OF TOP NAVBAR ======= -->
<div class="topNav"><a name="navbar_top">
<!-- -->
</a><a href="#skip-navbar_top" title="Skip navigation links"></a><a name="navbar_top_firstrow">
<!-- -->
</a>
<ul class="navList" title="Navigation">
<li><a href="../../../../overview-summary.html">Overview</a></li>
<li><a href="../package-summary.html">Package</a></li>
<li><a href="../../../../mk/tmdb/core/TMDbAuthentication.html" title="class in mk.tmdb.core">Class</a></li>
<li class="navBarCell1Rev">Use</li>
<li><a href="../package-tree.html">Tree</a></li>
<li><a href="../../../../deprecated-list.html">Deprecated</a></li>
<li><a href="../../../../index-files/index-1.html">Index</a></li>
<li><a href="../../../../help-doc.html">Help</a></li>
</ul>
</div>
<div class="subNav">
<ul class="navList">
<li>Prev</li>
<li>Next</li>
</ul>
<ul class="navList">
<li><a href="../../../../index.html?mk/tmdb/core/class-use/TMDbAuthentication.html" target="_top">Frames</a></li>
<li><a href="TMDbAuthentication.html" target="_top">No Frames</a></li>
</ul>
<ul class="navList" id="allclasses_navbar_top">
<li><a href="../../../../allclasses-noframe.html">All Classes</a></li>
</ul>
<div>
<script type="text/javascript"><!--
allClassesLink = document.getElementById("allclasses_navbar_top");
if(window==top) {
allClassesLink.style.display = "block";
}
else {
allClassesLink.style.display = "none";
}
//-->
</script>
</div>
<a name="skip-navbar_top">
<!-- -->
</a></div>
<!-- ========= END OF TOP NAVBAR ========= -->
<div class="header">
<h2 title="Uses of Class mk.tmdb.core.TMDbAuthentication" class="title">Uses of Class<br>mk.tmdb.core.TMDbAuthentication</h2>
</div>
<div class="classUseContainer">No usage of mk.tmdb.core.TMDbAuthentication</div>
<!-- ======= START OF BOTTOM NAVBAR ====== -->
<div class="bottomNav"><a name="navbar_bottom">
<!-- -->
</a><a href="#skip-navbar_bottom" title="Skip navigation links"></a><a name="navbar_bottom_firstrow">
<!-- -->
</a>
<ul class="navList" title="Navigation">
<li><a href="../../../../overview-summary.html">Overview</a></li>
<li><a href="../package-summary.html">Package</a></li>
<li><a href="../../../../mk/tmdb/core/TMDbAuthentication.html" title="class in mk.tmdb.core">Class</a></li>
<li class="navBarCell1Rev">Use</li>
<li><a href="../package-tree.html">Tree</a></li>
<li><a href="../../../../deprecated-list.html">Deprecated</a></li>
<li><a href="../../../../index-files/index-1.html">Index</a></li>
<li><a href="../../../../help-doc.html">Help</a></li>
</ul>
</div>
<div class="subNav">
<ul class="navList">
<li>Prev</li>
<li>Next</li>
</ul>
<ul class="navList">
<li><a href="../../../../index.html?mk/tmdb/core/class-use/TMDbAuthentication.html" target="_top">Frames</a></li>
<li><a href="TMDbAuthentication.html" target="_top">No Frames</a></li>
</ul>
<ul class="navList" id="allclasses_navbar_bottom">
<li><a href="../../../../allclasses-noframe.html">All Classes</a></li>
</ul>
<div>
<script type="text/javascript"><!--
allClassesLink = document.getElementById("allclasses_navbar_bottom");
if(window==top) {
allClassesLink.style.display = "block";
}
else {
allClassesLink.style.display = "none";
}
//-->
</script>
</div>
<a name="skip-navbar_bottom">
<!-- -->
</a></div>
<!-- ======== END OF BOTTOM NAVBAR ======= -->
</body>
</html>
| makgyver/MKtmdb | doc/mk/tmdb/core/class-use/TMDbAuthentication.html | HTML | gpl-3.0 | 4,044 | [
30522,
1026,
999,
9986,
13874,
16129,
2270,
1000,
1011,
1013,
1013,
1059,
2509,
2278,
1013,
1013,
26718,
2094,
16129,
1018,
1012,
5890,
17459,
1013,
1013,
4372,
1000,
1000,
8299,
1024,
1013,
1013,
7479,
1012,
1059,
2509,
1012,
8917,
1013,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
# 001-gentoo-install-x86_stage3.sh -- Gentoo Stage 3 install script v0.1
# Copyright (C) 2011 Vishwanath Venkataraman (thelinuxguyis@yahoo.co.in)
# This program is relased under GNU GPL Version 3, 29 June 2007
# For conditions of distribution and use, see copyright notice in COPYRIGHT.txt
# This is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
# PARTICULAR PURPOSE.
# See the GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
#! /bin/bash
#set -x
# ANSI Color Snippet Picked up from Wicket Cool Shell Scripts Book
# http://www.intuitive.com/wicked/showscript.cgi?011-colors.sh
# All Credits go to Author - Dave Taylor
# ANSI Color -- use these variables to easily have different color
# and format output. Make sure to output the reset sequence after
# colors (f = foreground, b = background), and use the 'off'
# feature for anything you turn on.
esc="\033"
blackf="${esc}[30m"; redf="${esc}[31m"; greenf="${esc}[32m"
yellowf="${esc}[33m" bluef="${esc}[34m"; purplef="${esc}[35m"
cyanf="${esc}[36m"; whitef="${esc}[37m"
blackb="${esc}[40m"; redb="${esc}[41m"; greenb="${esc}[42m"
yellowb="${esc}[43m" blueb="${esc}[44m"; purpleb="${esc}[45m"
cyanb="${esc}[46m"; whiteb="${esc}[47m"
boldon="${esc}[1m"; boldoff="${esc}[22m"
italicson="${esc}[3m"; italicsoff="${esc}[23m"
ulon="${esc}[4m"; uloff="${esc}[24m"
invon="${esc}[7m"; invoff="${esc}[27m"
reset="${esc}[0m"
## BASE CONFIG ##
GENTOO_CONF_FILES="gentoo-conf"
INSTALL_PATH="/mnt/gentoo"
PWD=`pwd`
SETUP_DIR=$PWD
clear;
setup_device()
{
echo -e "${boldon}${redf}Starting Gentoo 32-bit Install for Stage 3....${reset}"
sleep 5;
echo -e "${boldon}${redf}Enter the Partition name for Gentoo Install: ${reset}"
read device_partition
echo -e "${boldon}${yellowf}You have entered Device: $device_partition ${reset}"
echo -e "${boldon}${redf}NOTE: ALL DATA in $device_partition will be LOST !!! ${reset}"
echo -e "${boldon}${greenf}Type [yes or no] to proceed :${reset}"
read device_ans
case $device_ans in
yes) ;;
no) exit 1;
;;
*) echo "Invalid input"; exit 1;
;;
esac
echo -e "${boldon}${redf}Enter the Partition name for SWAP: ${reset}"
read swap_partition
echo -e "${boldon}${yellowf}You have entered Device: $swap_partition ${reset}"
echo -e "${boldon}${redf}NOTE: ALL DATA in $swap_partition will be LOST !!! ${reset}"
echo -e "${boldon}${greenf}Type [yes or no] to proceed :${reset}"
read swap_ans
case $swap_ans in
yes) ;;
no) exit 1;
;;
*) echo "Invalid input"; exit 1;
;;
esac
INSTALL_DEVICE=$device_partition
SWAP_DEVICE=$swap_partition
}
start_stage3()
{
echo -e "${yellowf}Created Gentoo Install Directory....${reset}"
mkdir -p $INSTALL_PATH;
sleep 5;
echo -e "${yellowf}Created ext4 fs for $INSTALL_DEVICE....${reset}"
sleep 10;
mke2fs -t ext4 $INSTALL_DEVICE;
echo -e "${yellowf}Activated SWAP for $SWAP_DEVICE....${reset}"
sleep 10;
mkswap $SWAP_DEVICE;
echo -e "${yellowf}Changing to Gentoo Directory....${reset}"
mount $INSTALL_DEVICE $INSTALL_PATH/;
}
download_stage3_files()
{
cd $INSTALL_PATH/;
echo -e "${yellowf}Downloading Stage3 Files....${reset}"
wget http://gentoo.osuosl.org/releases/x86/autobuilds/current-stage3/stage3-i686-20110503.tar.bz2;
wget http://gentoo.osuosl.org/releases/x86/autobuilds/current-stage3/stage3-i686-20110503.tar.bz2.CONTENTS;
wget http://gentoo.osuosl.org/releases/x86/autobuilds/current-stage3/stage3-i686-20110503.tar.bz2.DIGESTS;
sleep 2;
echo -e "${yellowf}Downloading Portage Files....${reset}"
wget http://gentoo.osuosl.org/snapshots/portage-latest.tar.bz2 ;
wget http://gentoo.osuosl.org/snapshots/portage-latest.tar.bz2.gpgsig ;
wget http://gentoo.osuosl.org/snapshots/portage-latest.tar.bz2.md5sum ;
sleep 2;
echo -e "${greenf}MD5SUM Completed....${reset}"
md5sum -c stage3-*.DIGESTS ;
md5sum -c portage-*.md5sum ;
sleep 2;
echo -e "${greenf}Untarring Stage3 files....${reset}"
tar --numeric-owner -xvjpf stage3-*.tar.bz2
sleep 2;
echo -e "${greenf}Untarring Portage Files....${reset}"
tar xvjf $INSTALL_PATH/portage-latest.tar.bz2 -C $INSTALL_PATH/usr
sleep 5;
}
finish_stage3()
{
echo -e "${greenf}Copying Gentoo specific Config files....${reset}"
cd $SETUP_DIR
#Default Gentoo Config files
cp $GENTOO_CONF_FILES/localtime.gentoo $INSTALL_PATH/etc/localtime ;
cp $GENTOO_CONF_FILES/locale.gen.gentoo $INSTALL_PATH/etc/locale.gen ;
cp $GENTOO_CONF_FILES/rc.conf.gentoo $INSTALL_PATH/etc/rc.conf ;
cp $GENTOO_CONF_FILES/keymaps.gentoo $INSTALL_PATH/etc/conf.d/keymaps ;
cp $GENTOO_CONF_FILES/clock.gentoo $INSTALL_PATH/etc/conf.d/clock ;
cp $GENTOO_CONF_FILES/wifi.gentoo $INSTALL_PATH/root/wpa_supplicant.conf;
cp $GENTOO_CONF_FILES/fstab.gentoo $INSTALL_PATH/etc/fstab ;
cp $GENTOO_CONF_FILES/hostname.gentoo $INSTALL_PATH/etc/conf.d/hostname ;
cp $GENTOO_CONF_FILES/hosts.gentoo $INSTALL_PATH/etc/hosts ;
#Custom Gentoo Config files
cp scripts/002-gentoo-configure-x86_stage3.sh $INSTALL_PATH/root/;
cp $GENTOO_CONF_FILES/make.conf.gentoo $INSTALL_PATH/etc/make.conf ;
cp $GENTOO_CONF_FILES/net.gentoo.eth0 $INSTALL_PATH/etc/conf.d/net ;
cp $GENTOO_CONF_FILES/resolv.conf.gentoo $INSTALL_PATH/etc/resolv.conf ;
cp $GENTOO_CONF_FILES/resolv.conf.gentoo $INSTALL_PATH/root/resolv.conf ;
mkdir -p $INSTALL_PATH/etc/portage
cp $GENTOO_CONF_FILES/package.* $INSTALL_PATH/root/
cp $GENTOO_CONF_FILES/package.use.gentoo $INSTALL_PATH/etc/portage/package.use
cp $GENTOO_CONF_FILES/package.license.gentoo $INSTALL_PATH/etc/portage/package.license
cp $GENTOO_CONF_FILES/grub.conf.gentoo.vm $INSTALL_PATH/root/
cp $GENTOO_CONF_FILES/grub.conf.gentoo.sda $INSTALL_PATH/root/
cp $GENTOO_CONF_FILES/fluxbox.startup.gentoo $INSTALL_PATH/root/
cp $GENTOO_CONF_FILES/conkyrc.gentoo $INSTALL_PATH/root/
cp $GENTOO_CONF_FILES/grub_buddha_tux.xpm.gz $INSTALL_PATH/root/
echo -e "${yellowf}Its Time to chroot....${reset}"
echo -e "${boldon}${redf}Now run ./chroot2Gentoo-0.1.sh to enter Your Gentoo Environment${reset}"
echo -e "${boldon}${redf}Next:Please run Gentoo Stage 3 Configure script !!! ${reset}"
sleep 5;
}
setup_device
start_stage3
download_stage3_files
finish_stage3
| Spingentoo/FluxboxSpins86 | scripts/001-gentoo-install-x86_stage3.sh | Shell | gpl-3.0 | 6,826 | [
30522,
1001,
25604,
1011,
8991,
3406,
2080,
1011,
16500,
1011,
1060,
20842,
1035,
2754,
2509,
1012,
14021,
1011,
1011,
8991,
3406,
2080,
2754,
1017,
16500,
5896,
1058,
2692,
1012,
1015,
1001,
9385,
1006,
1039,
1007,
2249,
25292,
18663,
1620... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
import os
import platform
import sys
from logging.handlers import SysLogHandler
LOG_LEVELS = ['DEBUG', 'INFO', 'WARNING', 'ERROR', 'CRITICAL']
def get_logger_config(log_dir,
logging_env="no_env",
tracking_filename="tracking.log",
edx_filename="edx.log",
dev_env=False,
syslog_addr=None,
debug=False,
local_loglevel='INFO',
console_loglevel=None,
service_variant=None):
"""
Return the appropriate logging config dictionary. You should assign the
result of this to the LOGGING var in your settings. The reason it's done
this way instead of registering directly is because I didn't want to worry
about resetting the logging state if this is called multiple times when
settings are extended.
If dev_env is set to true logging will not be done via local rsyslogd,
instead, tracking and application logs will be dropped in log_dir.
"tracking_filename" and "edx_filename" are ignored unless dev_env
is set to true since otherwise logging is handled by rsyslogd.
"""
# Revert to INFO if an invalid string is passed in
if local_loglevel not in LOG_LEVELS:
local_loglevel = 'INFO'
if console_loglevel is None or console_loglevel not in LOG_LEVELS:
console_loglevel = 'DEBUG' if debug else 'INFO'
if service_variant is None:
# default to a blank string so that if SERVICE_VARIANT is not
# set we will not log to a sub directory
service_variant = ''
hostname = platform.node().split(".")[0]
syslog_format = ("[service_variant={service_variant}]"
"[%(name)s][env:{logging_env}] %(levelname)s "
"[{hostname} %(process)d] [%(filename)s:%(lineno)d] "
"- %(message)s").format(service_variant=service_variant,
logging_env=logging_env,
hostname=hostname)
handlers = ['console', 'local'] if debug else ['console',
'syslogger-remote', 'local']
logger_config = {
'version': 1,
'disable_existing_loggers': False,
'formatters': {
'standard': {
'format': '%(asctime)s %(levelname)s %(process)d '
'[%(name)s] %(filename)s:%(lineno)d - %(message)s',
},
'syslog_format': {'format': syslog_format},
'raw': {'format': '%(message)s'},
},
'handlers': {
'console': {
'level': console_loglevel,
'class': 'logging.StreamHandler',
'formatter': 'standard',
'stream': sys.stderr,
},
'syslogger-remote': {
'level': 'INFO',
'class': 'logging.handlers.SysLogHandler',
'address': syslog_addr,
'formatter': 'syslog_format',
},
'newrelic': {
'level': 'ERROR',
'class': 'lms.lib.newrelic_logging.NewRelicHandler',
'formatter': 'raw',
}
},
'loggers': {
'tracking': {
'handlers': ['tracking'],
'level': 'DEBUG',
'propagate': False,
},
'': {
'handlers': handlers,
'level': 'DEBUG',
'propagate': False
},
}
}
if dev_env:
tracking_file_loc = os.path.join(log_dir, tracking_filename)
edx_file_loc = os.path.join(log_dir, edx_filename)
logger_config['handlers'].update({
'local': {
'class': 'logging.handlers.RotatingFileHandler',
'level': local_loglevel,
'formatter': 'standard',
'filename': edx_file_loc,
'maxBytes': 1024 * 1024 * 2,
'backupCount': 5,
},
'tracking': {
'level': 'DEBUG',
'class': 'logging.handlers.RotatingFileHandler',
'filename': tracking_file_loc,
'formatter': 'raw',
'maxBytes': 1024 * 1024 * 2,
'backupCount': 5,
},
})
else:
# for production environments we will only
# log INFO and up
logger_config['loggers']['']['level'] = 'INFO'
logger_config['handlers'].update({
'local': {
'level': local_loglevel,
'class': 'logging.handlers.SysLogHandler',
'address': '/dev/log',
'formatter': 'syslog_format',
'facility': SysLogHandler.LOG_LOCAL0,
},
'tracking': {
'level': 'DEBUG',
'class': 'logging.handlers.SysLogHandler',
'address': '/dev/log',
'facility': SysLogHandler.LOG_LOCAL1,
'formatter': 'raw',
},
})
return logger_config
| yokose-ks/edx-platform | common/lib/logsettings.py | Python | agpl-3.0 | 5,212 | [
30522,
12324,
9808,
12324,
4132,
12324,
25353,
2015,
2013,
15899,
1012,
28213,
2015,
12324,
25353,
14540,
8649,
11774,
3917,
8833,
1035,
3798,
1027,
1031,
1005,
2139,
8569,
2290,
1005,
1010,
1005,
18558,
1005,
1010,
1005,
5432,
1005,
1010,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
/**
* Copyright (C) 2008 Atlassian
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.atlassian.theplugin.jira.api;
public class JIRAActionFieldBean extends AbstractJIRAConstantBean implements JIRAActionField {
private String fieldId;
public JIRAActionFieldBean(String fieldId, String name) {
super(fieldId.hashCode(), name, null);
this.fieldId = fieldId;
}
public JIRAActionFieldBean(JIRAActionFieldBean other) {
this(other.fieldId, other.name);
}
public String getQueryStringFragment() {
// todo: I am almost absolutely sure this is wrong. Once we get
// to actually handling action fields, this will have to be fixed
return fieldId + "=";
}
public JIRAActionFieldBean getClone() {
return new JIRAActionFieldBean(this);
}
}
| joewalnes/idea-community | plugins/tasks/jira-connector/src/atlassian/java/com/atlassian/theplugin/jira/api/JIRAActionFieldBean.java | Java | apache-2.0 | 1,281 | [
30522,
1013,
1008,
1008,
1008,
9385,
1006,
1039,
1007,
2263,
11568,
17043,
1008,
1008,
7000,
2104,
1996,
15895,
6105,
1010,
2544,
1016,
1012,
1014,
1006,
1996,
1000,
6105,
1000,
1007,
1025,
1008,
2017,
2089,
2025,
2224,
2023,
5371,
3272,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
cmd_lib/libcrc32c.o := arm-eabi-gcc -Wp,-MD,lib/.libcrc32c.o.d -nostdinc -isystem /home/tim/ICS/prebuilt/linux-x86/toolchain/arm-eabi-4.4.0/bin/../lib/gcc/arm-eabi/4.4.0/include -I/home/tim/Downloads/mitchtaydev-Thrive-Shiva-Kernel-ee65d90/linux-2.6/arch/arm/include -Iinclude -include include/generated/autoconf.h -D__KERNEL__ -mlittle-endian -Iarch/arm/mach-tegra/include -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs -fno-strict-aliasing -fno-common -Werror-implicit-function-declaration -Wno-format-security -fno-delete-null-pointer-checks -Os -marm -fno-dwarf2-cfi-asm -mabi=aapcs-linux -mno-thumb-interwork -funwind-tables -D__LINUX_ARM_ARCH__=7 -march=armv7-a -msoft-float -Uarm -Wframe-larger-than=1024 -fno-stack-protector -fomit-frame-pointer -g -Wdeclaration-after-statement -Wno-pointer-sign -fno-strict-overflow -fconserve-stack -D"KBUILD_STR(s)=\#s" -D"KBUILD_BASENAME=KBUILD_STR(libcrc32c)" -D"KBUILD_MODNAME=KBUILD_STR(libcrc32c)" -c -o lib/libcrc32c.o lib/libcrc32c.c
deps_lib/libcrc32c.o := \
lib/libcrc32c.c \
include/crypto/hash.h \
include/linux/crypto.h \
/home/tim/Downloads/mitchtaydev-Thrive-Shiva-Kernel-ee65d90/linux-2.6/arch/arm/include/asm/atomic.h \
$(wildcard include/config/smp.h) \
$(wildcard include/config/generic/atomic64.h) \
include/linux/compiler.h \
$(wildcard include/config/trace/branch/profiling.h) \
$(wildcard include/config/profile/all/branches.h) \
$(wildcard include/config/enable/must/check.h) \
$(wildcard include/config/enable/warn/deprecated.h) \
include/linux/compiler-gcc.h \
$(wildcard include/config/arch/supports/optimized/inlining.h) \
$(wildcard include/config/optimize/inlining.h) \
include/linux/compiler-gcc4.h \
include/linux/types.h \
$(wildcard include/config/uid16.h) \
$(wildcard include/config/lbdaf.h) \
$(wildcard include/config/phys/addr/t/64bit.h) \
$(wildcard include/config/64bit.h) \
/home/tim/Downloads/mitchtaydev-Thrive-Shiva-Kernel-ee65d90/linux-2.6/arch/arm/include/asm/types.h \
include/asm-generic/int-ll64.h \
/home/tim/Downloads/mitchtaydev-Thrive-Shiva-Kernel-ee65d90/linux-2.6/arch/arm/include/asm/bitsperlong.h \
include/asm-generic/bitsperlong.h \
include/linux/posix_types.h \
include/linux/stddef.h \
/home/tim/Downloads/mitchtaydev-Thrive-Shiva-Kernel-ee65d90/linux-2.6/arch/arm/include/asm/posix_types.h \
/home/tim/Downloads/mitchtaydev-Thrive-Shiva-Kernel-ee65d90/linux-2.6/arch/arm/include/asm/system.h \
$(wildcard include/config/cpu/xsc3.h) \
$(wildcard include/config/cpu/fa526.h) \
$(wildcard include/config/arch/has/barriers.h) \
$(wildcard include/config/arm/dma/mem/bufferable.h) \
$(wildcard include/config/cpu/sa1100.h) \
$(wildcard include/config/cpu/sa110.h) \
$(wildcard include/config/cpu/32v6k.h) \
include/linux/linkage.h \
/home/tim/Downloads/mitchtaydev-Thrive-Shiva-Kernel-ee65d90/linux-2.6/arch/arm/include/asm/linkage.h \
include/linux/irqflags.h \
$(wildcard include/config/trace/irqflags.h) \
$(wildcard include/config/irqsoff/tracer.h) \
$(wildcard include/config/preempt/tracer.h) \
$(wildcard include/config/trace/irqflags/support.h) \
include/linux/typecheck.h \
/home/tim/Downloads/mitchtaydev-Thrive-Shiva-Kernel-ee65d90/linux-2.6/arch/arm/include/asm/irqflags.h \
/home/tim/Downloads/mitchtaydev-Thrive-Shiva-Kernel-ee65d90/linux-2.6/arch/arm/include/asm/ptrace.h \
$(wildcard include/config/cpu/endian/be8.h) \
$(wildcard include/config/arm/thumb.h) \
/home/tim/Downloads/mitchtaydev-Thrive-Shiva-Kernel-ee65d90/linux-2.6/arch/arm/include/asm/hwcap.h \
/home/tim/Downloads/mitchtaydev-Thrive-Shiva-Kernel-ee65d90/linux-2.6/arch/arm/include/asm/outercache.h \
$(wildcard include/config/outer/cache/sync.h) \
$(wildcard include/config/outer/cache.h) \
arch/arm/mach-tegra/include/mach/barriers.h \
include/asm-generic/cmpxchg-local.h \
include/asm-generic/atomic-long.h \
include/linux/module.h \
$(wildcard include/config/symbol/prefix.h) \
$(wildcard include/config/modules.h) \
$(wildcard include/config/modversions.h) \
$(wildcard include/config/unused/symbols.h) \
$(wildcard include/config/generic/bug.h) \
$(wildcard include/config/kallsyms.h) \
$(wildcard include/config/tracepoints.h) \
$(wildcard include/config/tracing.h) \
$(wildcard include/config/event/tracing.h) \
$(wildcard include/config/ftrace/mcount/record.h) \
$(wildcard include/config/module/unload.h) \
$(wildcard include/config/constructors.h) \
$(wildcard include/config/sysfs.h) \
include/linux/list.h \
$(wildcard include/config/debug/list.h) \
include/linux/poison.h \
$(wildcard include/config/illegal/pointer/value.h) \
include/linux/prefetch.h \
/home/tim/Downloads/mitchtaydev-Thrive-Shiva-Kernel-ee65d90/linux-2.6/arch/arm/include/asm/processor.h \
$(wildcard include/config/mmu.h) \
/home/tim/Downloads/mitchtaydev-Thrive-Shiva-Kernel-ee65d90/linux-2.6/arch/arm/include/asm/cache.h \
$(wildcard include/config/arm/l1/cache/shift.h) \
$(wildcard include/config/aeabi.h) \
include/linux/stat.h \
/home/tim/Downloads/mitchtaydev-Thrive-Shiva-Kernel-ee65d90/linux-2.6/arch/arm/include/asm/stat.h \
include/linux/time.h \
$(wildcard include/config/arch/uses/gettimeoffset.h) \
include/linux/cache.h \
$(wildcard include/config/arch/has/cache/line/size.h) \
include/linux/kernel.h \
$(wildcard include/config/preempt/voluntary.h) \
$(wildcard include/config/debug/spinlock/sleep.h) \
$(wildcard include/config/prove/locking.h) \
$(wildcard include/config/printk.h) \
$(wildcard include/config/dynamic/debug.h) \
$(wildcard include/config/ring/buffer.h) \
$(wildcard include/config/numa.h) \
/home/tim/ICS/prebuilt/linux-x86/toolchain/arm-eabi-4.4.0/bin/../lib/gcc/arm-eabi/4.4.0/include/stdarg.h \
include/linux/bitops.h \
$(wildcard include/config/generic/find/first/bit.h) \
$(wildcard include/config/generic/find/last/bit.h) \
$(wildcard include/config/generic/find/next/bit.h) \
/home/tim/Downloads/mitchtaydev-Thrive-Shiva-Kernel-ee65d90/linux-2.6/arch/arm/include/asm/bitops.h \
include/asm-generic/bitops/non-atomic.h \
include/asm-generic/bitops/fls64.h \
include/asm-generic/bitops/sched.h \
include/asm-generic/bitops/hweight.h \
include/asm-generic/bitops/arch_hweight.h \
include/asm-generic/bitops/const_hweight.h \
include/asm-generic/bitops/lock.h \
include/linux/log2.h \
$(wildcard include/config/arch/has/ilog2/u32.h) \
$(wildcard include/config/arch/has/ilog2/u64.h) \
include/linux/dynamic_debug.h \
/home/tim/Downloads/mitchtaydev-Thrive-Shiva-Kernel-ee65d90/linux-2.6/arch/arm/include/asm/byteorder.h \
include/linux/byteorder/little_endian.h \
include/linux/swab.h \
/home/tim/Downloads/mitchtaydev-Thrive-Shiva-Kernel-ee65d90/linux-2.6/arch/arm/include/asm/swab.h \
include/linux/byteorder/generic.h \
/home/tim/Downloads/mitchtaydev-Thrive-Shiva-Kernel-ee65d90/linux-2.6/arch/arm/include/asm/bug.h \
$(wildcard include/config/bug.h) \
$(wildcard include/config/debug/bugverbose.h) \
include/asm-generic/bug.h \
$(wildcard include/config/generic/bug/relative/pointers.h) \
/home/tim/Downloads/mitchtaydev-Thrive-Shiva-Kernel-ee65d90/linux-2.6/arch/arm/include/asm/div64.h \
include/linux/seqlock.h \
include/linux/spinlock.h \
$(wildcard include/config/debug/spinlock.h) \
$(wildcard include/config/generic/lockbreak.h) \
$(wildcard include/config/preempt.h) \
$(wildcard include/config/debug/lock/alloc.h) \
include/linux/preempt.h \
$(wildcard include/config/debug/preempt.h) \
$(wildcard include/config/preempt/notifiers.h) \
include/linux/thread_info.h \
$(wildcard include/config/compat.h) \
/home/tim/Downloads/mitchtaydev-Thrive-Shiva-Kernel-ee65d90/linux-2.6/arch/arm/include/asm/thread_info.h \
$(wildcard include/config/arm/thumbee.h) \
/home/tim/Downloads/mitchtaydev-Thrive-Shiva-Kernel-ee65d90/linux-2.6/arch/arm/include/asm/fpstate.h \
$(wildcard include/config/vfpv3.h) \
$(wildcard include/config/iwmmxt.h) \
/home/tim/Downloads/mitchtaydev-Thrive-Shiva-Kernel-ee65d90/linux-2.6/arch/arm/include/asm/domain.h \
$(wildcard include/config/io/36.h) \
include/linux/stringify.h \
include/linux/bottom_half.h \
include/linux/spinlock_types.h \
/home/tim/Downloads/mitchtaydev-Thrive-Shiva-Kernel-ee65d90/linux-2.6/arch/arm/include/asm/spinlock_types.h \
include/linux/lockdep.h \
$(wildcard include/config/lockdep.h) \
$(wildcard include/config/lock/stat.h) \
$(wildcard include/config/generic/hardirqs.h) \
$(wildcard include/config/prove/rcu.h) \
include/linux/rwlock_types.h \
/home/tim/Downloads/mitchtaydev-Thrive-Shiva-Kernel-ee65d90/linux-2.6/arch/arm/include/asm/spinlock.h \
include/linux/rwlock.h \
include/linux/spinlock_api_smp.h \
$(wildcard include/config/inline/spin/lock.h) \
$(wildcard include/config/inline/spin/lock/bh.h) \
$(wildcard include/config/inline/spin/lock/irq.h) \
$(wildcard include/config/inline/spin/lock/irqsave.h) \
$(wildcard include/config/inline/spin/trylock.h) \
$(wildcard include/config/inline/spin/trylock/bh.h) \
$(wildcard include/config/inline/spin/unlock.h) \
$(wildcard include/config/inline/spin/unlock/bh.h) \
$(wildcard include/config/inline/spin/unlock/irq.h) \
$(wildcard include/config/inline/spin/unlock/irqrestore.h) \
include/linux/rwlock_api_smp.h \
$(wildcard include/config/inline/read/lock.h) \
$(wildcard include/config/inline/write/lock.h) \
$(wildcard include/config/inline/read/lock/bh.h) \
$(wildcard include/config/inline/write/lock/bh.h) \
$(wildcard include/config/inline/read/lock/irq.h) \
$(wildcard include/config/inline/write/lock/irq.h) \
$(wildcard include/config/inline/read/lock/irqsave.h) \
$(wildcard include/config/inline/write/lock/irqsave.h) \
$(wildcard include/config/inline/read/trylock.h) \
$(wildcard include/config/inline/write/trylock.h) \
$(wildcard include/config/inline/read/unlock.h) \
$(wildcard include/config/inline/write/unlock.h) \
$(wildcard include/config/inline/read/unlock/bh.h) \
$(wildcard include/config/inline/write/unlock/bh.h) \
$(wildcard include/config/inline/read/unlock/irq.h) \
$(wildcard include/config/inline/write/unlock/irq.h) \
$(wildcard include/config/inline/read/unlock/irqrestore.h) \
$(wildcard include/config/inline/write/unlock/irqrestore.h) \
include/linux/math64.h \
include/linux/kmod.h \
include/linux/gfp.h \
$(wildcard include/config/kmemcheck.h) \
$(wildcard include/config/highmem.h) \
$(wildcard include/config/zone/dma.h) \
$(wildcard include/config/zone/dma32.h) \
$(wildcard include/config/debug/vm.h) \
include/linux/mmzone.h \
$(wildcard include/config/force/max/zoneorder.h) \
$(wildcard include/config/memory/hotplug.h) \
$(wildcard include/config/sparsemem.h) \
$(wildcard include/config/compaction.h) \
$(wildcard include/config/arch/populates/node/map.h) \
$(wildcard include/config/discontigmem.h) \
$(wildcard include/config/flat/node/mem/map.h) \
$(wildcard include/config/cgroup/mem/res/ctlr.h) \
$(wildcard include/config/no/bootmem.h) \
$(wildcard include/config/have/memory/present.h) \
$(wildcard include/config/have/memoryless/nodes.h) \
$(wildcard include/config/need/node/memmap/size.h) \
$(wildcard include/config/need/multiple/nodes.h) \
$(wildcard include/config/have/arch/early/pfn/to/nid.h) \
$(wildcard include/config/flatmem.h) \
$(wildcard include/config/sparsemem/extreme.h) \
$(wildcard include/config/nodes/span/other/nodes.h) \
$(wildcard include/config/holes/in/zone.h) \
$(wildcard include/config/arch/has/holes/memorymodel.h) \
include/linux/wait.h \
/home/tim/Downloads/mitchtaydev-Thrive-Shiva-Kernel-ee65d90/linux-2.6/arch/arm/include/asm/current.h \
include/linux/threads.h \
$(wildcard include/config/nr/cpus.h) \
$(wildcard include/config/base/small.h) \
include/linux/numa.h \
$(wildcard include/config/nodes/shift.h) \
include/linux/init.h \
$(wildcard include/config/hotplug.h) \
include/linux/nodemask.h \
include/linux/bitmap.h \
include/linux/string.h \
$(wildcard include/config/binary/printf.h) \
/home/tim/Downloads/mitchtaydev-Thrive-Shiva-Kernel-ee65d90/linux-2.6/arch/arm/include/asm/string.h \
include/linux/pageblock-flags.h \
$(wildcard include/config/hugetlb/page.h) \
$(wildcard include/config/hugetlb/page/size/variable.h) \
include/generated/bounds.h \
/home/tim/Downloads/mitchtaydev-Thrive-Shiva-Kernel-ee65d90/linux-2.6/arch/arm/include/asm/page.h \
$(wildcard include/config/cpu/copy/v3.h) \
$(wildcard include/config/cpu/copy/v4wt.h) \
$(wildcard include/config/cpu/copy/v4wb.h) \
$(wildcard include/config/cpu/copy/feroceon.h) \
$(wildcard include/config/cpu/copy/fa.h) \
$(wildcard include/config/cpu/xscale.h) \
$(wildcard include/config/cpu/copy/v6.h) \
/home/tim/Downloads/mitchtaydev-Thrive-Shiva-Kernel-ee65d90/linux-2.6/arch/arm/include/asm/glue.h \
$(wildcard include/config/cpu/arm610.h) \
$(wildcard include/config/cpu/arm710.h) \
$(wildcard include/config/cpu/abrt/lv4t.h) \
$(wildcard include/config/cpu/abrt/ev4.h) \
$(wildcard include/config/cpu/abrt/ev4t.h) \
$(wildcard include/config/cpu/abrt/ev5tj.h) \
$(wildcard include/config/cpu/abrt/ev5t.h) \
$(wildcard include/config/cpu/abrt/ev6.h) \
$(wildcard include/config/cpu/abrt/ev7.h) \
$(wildcard include/config/cpu/pabrt/legacy.h) \
$(wildcard include/config/cpu/pabrt/v6.h) \
$(wildcard include/config/cpu/pabrt/v7.h) \
/home/tim/Downloads/mitchtaydev-Thrive-Shiva-Kernel-ee65d90/linux-2.6/arch/arm/include/asm/memory.h \
$(wildcard include/config/page/offset.h) \
$(wildcard include/config/thumb2/kernel.h) \
$(wildcard include/config/dram/size.h) \
$(wildcard include/config/dram/base.h) \
$(wildcard include/config/have/tcm.h) \
include/linux/const.h \
arch/arm/mach-tegra/include/mach/memory.h \
/home/tim/Downloads/mitchtaydev-Thrive-Shiva-Kernel-ee65d90/linux-2.6/arch/arm/include/asm/sizes.h \
include/asm-generic/memory_model.h \
$(wildcard include/config/sparsemem/vmemmap.h) \
include/asm-generic/getorder.h \
include/linux/memory_hotplug.h \
$(wildcard include/config/have/arch/nodedata/extension.h) \
$(wildcard include/config/memory/hotremove.h) \
include/linux/notifier.h \
include/linux/errno.h \
/home/tim/Downloads/mitchtaydev-Thrive-Shiva-Kernel-ee65d90/linux-2.6/arch/arm/include/asm/errno.h \
include/asm-generic/errno.h \
include/asm-generic/errno-base.h \
include/linux/mutex.h \
$(wildcard include/config/debug/mutexes.h) \
include/linux/rwsem.h \
$(wildcard include/config/rwsem/generic/spinlock.h) \
include/linux/rwsem-spinlock.h \
include/linux/srcu.h \
include/linux/topology.h \
$(wildcard include/config/sched/smt.h) \
$(wildcard include/config/sched/mc.h) \
$(wildcard include/config/use/percpu/numa/node/id.h) \
include/linux/cpumask.h \
$(wildcard include/config/cpumask/offstack.h) \
$(wildcard include/config/hotplug/cpu.h) \
$(wildcard include/config/debug/per/cpu/maps.h) \
$(wildcard include/config/disable/obsolete/cpumask/functions.h) \
include/linux/smp.h \
$(wildcard include/config/use/generic/smp/helpers.h) \
/home/tim/Downloads/mitchtaydev-Thrive-Shiva-Kernel-ee65d90/linux-2.6/arch/arm/include/asm/smp.h \
arch/arm/mach-tegra/include/mach/smp.h \
/home/tim/Downloads/mitchtaydev-Thrive-Shiva-Kernel-ee65d90/linux-2.6/arch/arm/include/asm/hardware/gic.h \
include/linux/percpu.h \
$(wildcard include/config/need/per/cpu/embed/first/chunk.h) \
$(wildcard include/config/need/per/cpu/page/first/chunk.h) \
$(wildcard include/config/have/setup/per/cpu/area.h) \
include/linux/pfn.h \
/home/tim/Downloads/mitchtaydev-Thrive-Shiva-Kernel-ee65d90/linux-2.6/arch/arm/include/asm/percpu.h \
include/asm-generic/percpu.h \
include/linux/percpu-defs.h \
$(wildcard include/config/debug/force/weak/per/cpu.h) \
/home/tim/Downloads/mitchtaydev-Thrive-Shiva-Kernel-ee65d90/linux-2.6/arch/arm/include/asm/topology.h \
include/asm-generic/topology.h \
include/linux/mmdebug.h \
$(wildcard include/config/debug/virtual.h) \
include/linux/workqueue.h \
$(wildcard include/config/debug/objects/work.h) \
$(wildcard include/config/freezer.h) \
include/linux/timer.h \
$(wildcard include/config/timer/stats.h) \
$(wildcard include/config/debug/objects/timers.h) \
include/linux/ktime.h \
$(wildcard include/config/ktime/scalar.h) \
include/linux/jiffies.h \
include/linux/timex.h \
include/linux/param.h \
/home/tim/Downloads/mitchtaydev-Thrive-Shiva-Kernel-ee65d90/linux-2.6/arch/arm/include/asm/param.h \
$(wildcard include/config/hz.h) \
/home/tim/Downloads/mitchtaydev-Thrive-Shiva-Kernel-ee65d90/linux-2.6/arch/arm/include/asm/timex.h \
arch/arm/mach-tegra/include/mach/timex.h \
include/linux/debugobjects.h \
$(wildcard include/config/debug/objects.h) \
$(wildcard include/config/debug/objects/free.h) \
include/linux/elf.h \
include/linux/elf-em.h \
/home/tim/Downloads/mitchtaydev-Thrive-Shiva-Kernel-ee65d90/linux-2.6/arch/arm/include/asm/elf.h \
/home/tim/Downloads/mitchtaydev-Thrive-Shiva-Kernel-ee65d90/linux-2.6/arch/arm/include/asm/user.h \
include/linux/kobject.h \
include/linux/sysfs.h \
include/linux/kobject_ns.h \
include/linux/kref.h \
include/linux/moduleparam.h \
$(wildcard include/config/alpha.h) \
$(wildcard include/config/ia64.h) \
$(wildcard include/config/ppc64.h) \
include/linux/tracepoint.h \
include/linux/rcupdate.h \
$(wildcard include/config/rcu/torture/test.h) \
$(wildcard include/config/tree/rcu.h) \
$(wildcard include/config/tree/preempt/rcu.h) \
$(wildcard include/config/tiny/rcu.h) \
$(wildcard include/config/debug/objects/rcu/head.h) \
include/linux/completion.h \
include/linux/rcutree.h \
$(wildcard include/config/no/hz.h) \
/home/tim/Downloads/mitchtaydev-Thrive-Shiva-Kernel-ee65d90/linux-2.6/arch/arm/include/asm/module.h \
$(wildcard include/config/arm/unwind.h) \
include/trace/events/module.h \
include/trace/define_trace.h \
include/linux/slab.h \
$(wildcard include/config/slab/debug.h) \
$(wildcard include/config/failslab.h) \
$(wildcard include/config/slub.h) \
$(wildcard include/config/slob.h) \
$(wildcard include/config/debug/slab.h) \
$(wildcard include/config/slab.h) \
include/linux/slab_def.h \
include/trace/events/kmem.h \
include/trace/events/gfpflags.h \
include/linux/kmalloc_sizes.h \
include/linux/uaccess.h \
/home/tim/Downloads/mitchtaydev-Thrive-Shiva-Kernel-ee65d90/linux-2.6/arch/arm/include/asm/uaccess.h \
/home/tim/Downloads/mitchtaydev-Thrive-Shiva-Kernel-ee65d90/linux-2.6/arch/arm/include/asm/unified.h \
$(wildcard include/config/arm/asm/unified.h) \
include/linux/err.h \
lib/libcrc32c.o: $(deps_lib/libcrc32c.o)
$(deps_lib/libcrc32c.o):
| timmytim/honeybutter_kernel | lib/.libcrc32c.o.cmd | Batchfile | gpl-2.0 | 19,301 | [
30522,
4642,
2094,
1035,
5622,
2497,
1013,
5622,
9818,
11890,
16703,
2278,
1012,
1051,
1024,
1027,
2849,
1011,
19413,
5638,
1011,
1043,
9468,
1011,
1059,
2361,
1010,
1011,
9108,
1010,
5622,
2497,
1013,
1012,
5622,
9818,
11890,
16703,
2278,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
<?php
namespace Nf;
class Db
{
const FETCH_ASSOC = 2;
const FETCH_NUM = 3;
const FETCH_OBJ = 5;
const FETCH_COLUMN = 7;
private static $_connections = array();
public static $_forceStoreConnectionInInstance = null;
public static function factory($config)
{
if (! is_array($config)) {
// convert to an array
$conf = array();
$conf['adapter'] = $config->adapter;
$conf['params'] = (array) $config->params;
$conf['profiler'] = (array) $config->profiler;
} else {
$conf = $config;
}
$adapterName = get_class() . '\\Adapter\\' . $conf['adapter'];
$dbAdapter = new $adapterName($conf['params']);
$dbAdapter->setProfilerConfig($conf['profiler']);
return $dbAdapter;
}
public static function getConnection($configName, $alternateHostname = null, $alternateDatabase = null, $storeInInstance = true)
{
$config = \Nf\Registry::get('config');
if (!isset($config->db->$configName)) {
throw new \Exception('The adapter "' . $configName . '" is not defined in the config file');
}
if (self::$_forceStoreConnectionInInstance !== null) {
$storeInInstance = self::$_forceStoreConnectionInInstance;
}
$defaultHostname = $config->db->$configName->params->hostname;
$defaultDatabase = $config->db->$configName->params->database;
$hostname = ($alternateHostname !== null) ? $alternateHostname : $defaultHostname;
$database = ($alternateDatabase !== null) ? $alternateDatabase : $defaultDatabase;
if (isset($config->db->$configName->params->port)) {
$port = $config->db->$configName->params->port;
} else {
$port = null;
}
// if the connection has already been created and if we store the connection in memory for future use
if (isset(self::$_connections[$configName . '-' . $hostname . '-' . $database]) && $storeInInstance) {
return self::$_connections[$configName . '-' . $hostname . '-' . $database];
} else {
// optional profiler config
$profilerConfig = isset($config->db->$configName->profiler) ? (array)$config->db->$configName->profiler : null;
if ($profilerConfig != null) {
$profilerConfig['name'] = $configName;
}
// or else we create a new connection
$dbConfig = array(
'adapter' => $config->db->$configName->adapter,
'params' => array(
'hostname' => $hostname,
'port' => $port,
'username' => $config->db->$configName->params->username,
'password' => $config->db->$configName->params->password,
'database' => $database,
'charset' => $config->db->$configName->params->charset
),
'profiler' => $profilerConfig
);
// connection with the factory method
$dbConnection = self::factory($dbConfig);
if ($storeInInstance) {
self::$_connections[$configName . '-' . $hostname . '-' . $database] = $dbConnection;
}
return $dbConnection;
}
}
}
| jarnix/nofussframework | Nf/Db.php | PHP | mit | 3,365 | [
30522,
1026,
1029,
25718,
3415,
15327,
1050,
2546,
1025,
2465,
16962,
1063,
9530,
3367,
18584,
1035,
4632,
10085,
1027,
1016,
1025,
9530,
3367,
18584,
1035,
16371,
2213,
1027,
1017,
1025,
9530,
3367,
18584,
1035,
27885,
3501,
1027,
1019,
10... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
/*
* Routines for driver control interface
* Copyright (c) by Jaroslav Kysela <perex@perex.cz>
*
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
#include <linux/threads.h>
#include <linux/interrupt.h>
#include <linux/module.h>
#include <linux/slab.h>
#include <linux/vmalloc.h>
#include <linux/time.h>
#include <sound/core.h>
#include <sound/minors.h>
#include <sound/info.h>
#include <sound/control.h>
/* max number of user-defined controls */
#define MAX_USER_CONTROLS 32
#define MAX_CONTROL_COUNT 1028
struct snd_kctl_ioctl {
struct list_head list; /* list of all ioctls */
snd_kctl_ioctl_func_t fioctl;
};
static DECLARE_RWSEM(snd_ioctl_rwsem);
static LIST_HEAD(snd_control_ioctls);
#ifdef CONFIG_COMPAT
static LIST_HEAD(snd_control_compat_ioctls);
#endif
static int snd_ctl_open(struct inode *inode, struct file *file)
{
unsigned long flags;
struct snd_card *card;
struct snd_ctl_file *ctl;
int err;
err = nonseekable_open(inode, file);
if (err < 0)
return err;
card = snd_lookup_minor_data(iminor(inode), SNDRV_DEVICE_TYPE_CONTROL);
if (!card) {
err = -ENODEV;
goto __error1;
}
err = snd_card_file_add(card, file);
if (err < 0) {
err = -ENODEV;
goto __error1;
}
if (!try_module_get(card->module)) {
err = -EFAULT;
goto __error2;
}
ctl = kzalloc(sizeof(*ctl), GFP_KERNEL);
if (ctl == NULL) {
err = -ENOMEM;
goto __error;
}
INIT_LIST_HEAD(&ctl->events);
init_waitqueue_head(&ctl->change_sleep);
spin_lock_init(&ctl->read_lock);
ctl->card = card;
ctl->prefer_pcm_subdevice = -1;
ctl->prefer_rawmidi_subdevice = -1;
ctl->pid = get_pid(task_pid(current));
file->private_data = ctl;
write_lock_irqsave(&card->ctl_files_rwlock, flags);
list_add_tail(&ctl->list, &card->ctl_files);
write_unlock_irqrestore(&card->ctl_files_rwlock, flags);
snd_card_unref(card);
return 0;
__error:
module_put(card->module);
__error2:
snd_card_file_remove(card, file);
__error1:
if (card)
snd_card_unref(card);
return err;
}
static void snd_ctl_empty_read_queue(struct snd_ctl_file * ctl)
{
unsigned long flags;
struct snd_kctl_event *cread;
spin_lock_irqsave(&ctl->read_lock, flags);
while (!list_empty(&ctl->events)) {
cread = snd_kctl_event(ctl->events.next);
list_del(&cread->list);
kfree(cread);
}
spin_unlock_irqrestore(&ctl->read_lock, flags);
}
static int snd_ctl_release(struct inode *inode, struct file *file)
{
unsigned long flags;
struct snd_card *card;
struct snd_ctl_file *ctl;
struct snd_kcontrol *control;
unsigned int idx;
ctl = file->private_data;
file->private_data = NULL;
card = ctl->card;
write_lock_irqsave(&card->ctl_files_rwlock, flags);
list_del(&ctl->list);
write_unlock_irqrestore(&card->ctl_files_rwlock, flags);
down_write(&card->controls_rwsem);
list_for_each_entry(control, &card->controls, list)
for (idx = 0; idx < control->count; idx++)
if (control->vd[idx].owner == ctl)
control->vd[idx].owner = NULL;
up_write(&card->controls_rwsem);
snd_ctl_empty_read_queue(ctl);
put_pid(ctl->pid);
kfree(ctl);
module_put(card->module);
snd_card_file_remove(card, file);
return 0;
}
void snd_ctl_notify(struct snd_card *card, unsigned int mask,
struct snd_ctl_elem_id *id)
{
unsigned long flags;
struct snd_ctl_file *ctl;
struct snd_kctl_event *ev;
if (snd_BUG_ON(!card || !id))
return;
read_lock(&card->ctl_files_rwlock);
#if defined(CONFIG_SND_MIXER_OSS) || defined(CONFIG_SND_MIXER_OSS_MODULE)
card->mixer_oss_change_count++;
#endif
list_for_each_entry(ctl, &card->ctl_files, list) {
if (!ctl->subscribed)
continue;
spin_lock_irqsave(&ctl->read_lock, flags);
list_for_each_entry(ev, &ctl->events, list) {
if (ev->id.numid == id->numid) {
ev->mask |= mask;
goto _found;
}
}
ev = kzalloc(sizeof(*ev), GFP_ATOMIC);
if (ev) {
ev->id = *id;
ev->mask = mask;
list_add_tail(&ev->list, &ctl->events);
} else {
snd_printk(KERN_ERR "No memory available to allocate event\n");
}
_found:
wake_up(&ctl->change_sleep);
spin_unlock_irqrestore(&ctl->read_lock, flags);
kill_fasync(&ctl->fasync, SIGIO, POLL_IN);
}
read_unlock(&card->ctl_files_rwlock);
}
EXPORT_SYMBOL(snd_ctl_notify);
/**
* snd_ctl_new - create a control instance from the template
* @control: the control template
* @access: the default control access
*
* Allocates a new struct snd_kcontrol instance and copies the given template
* to the new instance. It does not copy volatile data (access).
*
* Returns the pointer of the new instance, or NULL on failure.
*/
static struct snd_kcontrol *snd_ctl_new(struct snd_kcontrol *control,
unsigned int access)
{
struct snd_kcontrol *kctl;
unsigned int idx;
if (snd_BUG_ON(!control || !control->count))
return NULL;
if (control->count > MAX_CONTROL_COUNT)
return NULL;
kctl = kzalloc(sizeof(*kctl) + sizeof(struct snd_kcontrol_volatile) * control->count, GFP_KERNEL);
if (kctl == NULL) {
snd_printk(KERN_ERR "Cannot allocate control instance\n");
return NULL;
}
*kctl = *control;
for (idx = 0; idx < kctl->count; idx++)
kctl->vd[idx].access = access;
return kctl;
}
/**
* snd_ctl_new1 - create a control instance from the template
* @ncontrol: the initialization record
* @private_data: the private data to set
*
* Allocates a new struct snd_kcontrol instance and initialize from the given
* template. When the access field of ncontrol is 0, it's assumed as
* READWRITE access. When the count field is 0, it's assumes as one.
*
* Returns the pointer of the newly generated instance, or NULL on failure.
*/
struct snd_kcontrol *snd_ctl_new1(const struct snd_kcontrol_new *ncontrol,
void *private_data)
{
struct snd_kcontrol kctl;
unsigned int access;
if (snd_BUG_ON(!ncontrol || !ncontrol->info))
return NULL;
memset(&kctl, 0, sizeof(kctl));
kctl.id.iface = ncontrol->iface;
kctl.id.device = ncontrol->device;
kctl.id.subdevice = ncontrol->subdevice;
if (ncontrol->name) {
strlcpy(kctl.id.name, ncontrol->name, sizeof(kctl.id.name));
if (strcmp(ncontrol->name, kctl.id.name) != 0)
snd_printk(KERN_WARNING
"Control name '%s' truncated to '%s'\n",
ncontrol->name, kctl.id.name);
}
kctl.id.index = ncontrol->index;
kctl.count = ncontrol->count ? ncontrol->count : 1;
access = ncontrol->access == 0 ? SNDRV_CTL_ELEM_ACCESS_READWRITE :
(ncontrol->access & (SNDRV_CTL_ELEM_ACCESS_READWRITE|
SNDRV_CTL_ELEM_ACCESS_INACTIVE|
SNDRV_CTL_ELEM_ACCESS_TLV_READWRITE|
SNDRV_CTL_ELEM_ACCESS_TLV_COMMAND|
SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK));
kctl.info = ncontrol->info;
kctl.get = ncontrol->get;
kctl.put = ncontrol->put;
kctl.tlv.p = ncontrol->tlv.p;
kctl.private_value = ncontrol->private_value;
kctl.private_data = private_data;
return snd_ctl_new(&kctl, access);
}
EXPORT_SYMBOL(snd_ctl_new1);
/**
* snd_ctl_free_one - release the control instance
* @kcontrol: the control instance
*
* Releases the control instance created via snd_ctl_new()
* or snd_ctl_new1().
* Don't call this after the control was added to the card.
*/
void snd_ctl_free_one(struct snd_kcontrol *kcontrol)
{
if (kcontrol) {
if (kcontrol->private_free)
kcontrol->private_free(kcontrol);
kfree(kcontrol);
}
}
EXPORT_SYMBOL(snd_ctl_free_one);
static bool snd_ctl_remove_numid_conflict(struct snd_card *card,
unsigned int count)
{
struct snd_kcontrol *kctl;
/* Make sure that the ids assigned to the control do not wrap around */
if (card->last_numid >= UINT_MAX - count)
card->last_numid = 0;
list_for_each_entry(kctl, &card->controls, list) {
if (kctl->id.numid < card->last_numid + 1 + count &&
kctl->id.numid + kctl->count > card->last_numid + 1) {
card->last_numid = kctl->id.numid + kctl->count - 1;
return true;
}
}
return false;
}
static int snd_ctl_find_hole(struct snd_card *card, unsigned int count)
{
unsigned int iter = 100000;
while (snd_ctl_remove_numid_conflict(card, count)) {
if (--iter == 0) {
/* this situation is very unlikely */
snd_printk(KERN_ERR "unable to allocate new control numid\n");
return -ENOMEM;
}
}
return 0;
}
/**
* snd_ctl_add - add the control instance to the card
* @card: the card instance
* @kcontrol: the control instance to add
*
* Adds the control instance created via snd_ctl_new() or
* snd_ctl_new1() to the given card. Assigns also an unique
* numid used for fast search.
*
* Returns zero if successful, or a negative error code on failure.
*
* It frees automatically the control which cannot be added.
*/
int snd_ctl_add(struct snd_card *card, struct snd_kcontrol *kcontrol)
{
struct snd_ctl_elem_id id;
unsigned int idx;
unsigned int count;
int err = -EINVAL;
if (! kcontrol)
return err;
if (snd_BUG_ON(!card || !kcontrol->info))
goto error;
id = kcontrol->id;
if (id.index > UINT_MAX - kcontrol->count)
goto error;
down_write(&card->controls_rwsem);
if (snd_ctl_find_id(card, &id)) {
up_write(&card->controls_rwsem);
snd_printd(KERN_ERR "control %i:%i:%i:%s:%i is already present\n",
id.iface,
id.device,
id.subdevice,
id.name,
id.index);
err = -EBUSY;
goto error;
}
if (snd_ctl_find_hole(card, kcontrol->count) < 0) {
up_write(&card->controls_rwsem);
err = -ENOMEM;
goto error;
}
list_add_tail(&kcontrol->list, &card->controls);
card->controls_count += kcontrol->count;
kcontrol->id.numid = card->last_numid + 1;
card->last_numid += kcontrol->count;
count = kcontrol->count;
up_write(&card->controls_rwsem);
for (idx = 0; idx < count; idx++, id.index++, id.numid++)
snd_ctl_notify(card, SNDRV_CTL_EVENT_MASK_ADD, &id);
return 0;
error:
snd_ctl_free_one(kcontrol);
return err;
}
EXPORT_SYMBOL(snd_ctl_add);
/**
* snd_ctl_replace - replace the control instance of the card
* @card: the card instance
* @kcontrol: the control instance to replace
* @add_on_replace: add the control if not already added
*
* Replaces the given control. If the given control does not exist
* and the add_on_replace flag is set, the control is added. If the
* control exists, it is destroyed first.
*
* Returns zero if successful, or a negative error code on failure.
*
* It frees automatically the control which cannot be added or replaced.
*/
int snd_ctl_replace(struct snd_card *card, struct snd_kcontrol *kcontrol,
bool add_on_replace)
{
struct snd_ctl_elem_id id;
unsigned int count;
unsigned int idx;
struct snd_kcontrol *old;
int ret;
if (!kcontrol)
return -EINVAL;
if (snd_BUG_ON(!card || !kcontrol->info)) {
ret = -EINVAL;
goto error;
}
id = kcontrol->id;
down_write(&card->controls_rwsem);
old = snd_ctl_find_id(card, &id);
if (!old) {
if (add_on_replace)
goto add;
up_write(&card->controls_rwsem);
ret = -EINVAL;
goto error;
}
ret = snd_ctl_remove(card, old);
if (ret < 0) {
up_write(&card->controls_rwsem);
goto error;
}
add:
if (snd_ctl_find_hole(card, kcontrol->count) < 0) {
up_write(&card->controls_rwsem);
ret = -ENOMEM;
goto error;
}
list_add_tail(&kcontrol->list, &card->controls);
card->controls_count += kcontrol->count;
kcontrol->id.numid = card->last_numid + 1;
card->last_numid += kcontrol->count;
count = kcontrol->count;
up_write(&card->controls_rwsem);
for (idx = 0; idx < count; idx++, id.index++, id.numid++)
snd_ctl_notify(card, SNDRV_CTL_EVENT_MASK_ADD, &id);
return 0;
error:
snd_ctl_free_one(kcontrol);
return ret;
}
EXPORT_SYMBOL(snd_ctl_replace);
/**
* snd_ctl_remove - remove the control from the card and release it
* @card: the card instance
* @kcontrol: the control instance to remove
*
* Removes the control from the card and then releases the instance.
* You don't need to call snd_ctl_free_one(). You must be in
* the write lock - down_write(&card->controls_rwsem).
*
* Returns 0 if successful, or a negative error code on failure.
*/
int snd_ctl_remove(struct snd_card *card, struct snd_kcontrol *kcontrol)
{
struct snd_ctl_elem_id id;
unsigned int idx;
if (snd_BUG_ON(!card || !kcontrol))
return -EINVAL;
list_del(&kcontrol->list);
card->controls_count -= kcontrol->count;
id = kcontrol->id;
for (idx = 0; idx < kcontrol->count; idx++, id.index++, id.numid++)
snd_ctl_notify(card, SNDRV_CTL_EVENT_MASK_REMOVE, &id);
snd_ctl_free_one(kcontrol);
return 0;
}
EXPORT_SYMBOL(snd_ctl_remove);
/**
* snd_ctl_remove_id - remove the control of the given id and release it
* @card: the card instance
* @id: the control id to remove
*
* Finds the control instance with the given id, removes it from the
* card list and releases it.
*
* Returns 0 if successful, or a negative error code on failure.
*/
int snd_ctl_remove_id(struct snd_card *card, struct snd_ctl_elem_id *id)
{
struct snd_kcontrol *kctl;
int ret;
down_write(&card->controls_rwsem);
kctl = snd_ctl_find_id(card, id);
if (kctl == NULL) {
up_write(&card->controls_rwsem);
return -ENOENT;
}
ret = snd_ctl_remove(card, kctl);
up_write(&card->controls_rwsem);
return ret;
}
EXPORT_SYMBOL(snd_ctl_remove_id);
/**
* snd_ctl_remove_user_ctl - remove and release the unlocked user control
* @file: active control handle
* @id: the control id to remove
*
* Finds the control instance with the given id, removes it from the
* card list and releases it.
*
* Returns 0 if successful, or a negative error code on failure.
*/
static int snd_ctl_remove_user_ctl(struct snd_ctl_file * file,
struct snd_ctl_elem_id *id)
{
struct snd_card *card = file->card;
struct snd_kcontrol *kctl;
int idx, ret;
down_write(&card->controls_rwsem);
kctl = snd_ctl_find_id(card, id);
if (kctl == NULL) {
ret = -ENOENT;
goto error;
}
if (!(kctl->vd[0].access & SNDRV_CTL_ELEM_ACCESS_USER)) {
ret = -EINVAL;
goto error;
}
for (idx = 0; idx < kctl->count; idx++)
if (kctl->vd[idx].owner != NULL && kctl->vd[idx].owner != file) {
ret = -EBUSY;
goto error;
}
ret = snd_ctl_remove(card, kctl);
if (ret < 0)
goto error;
card->user_ctl_count--;
error:
up_write(&card->controls_rwsem);
return ret;
}
/**
* snd_ctl_activate_id - activate/inactivate the control of the given id
* @card: the card instance
* @id: the control id to activate/inactivate
* @active: non-zero to activate
*
* Finds the control instance with the given id, and activate or
* inactivate the control together with notification, if changed.
*
* Returns 0 if unchanged, 1 if changed, or a negative error code on failure.
*/
int snd_ctl_activate_id(struct snd_card *card, struct snd_ctl_elem_id *id,
int active)
{
struct snd_kcontrol *kctl;
struct snd_kcontrol_volatile *vd;
unsigned int index_offset;
int ret;
down_write(&card->controls_rwsem);
kctl = snd_ctl_find_id(card, id);
if (kctl == NULL) {
ret = -ENOENT;
goto unlock;
}
index_offset = snd_ctl_get_ioff(kctl, &kctl->id);
vd = &kctl->vd[index_offset];
ret = 0;
if (active) {
if (!(vd->access & SNDRV_CTL_ELEM_ACCESS_INACTIVE))
goto unlock;
vd->access &= ~SNDRV_CTL_ELEM_ACCESS_INACTIVE;
} else {
if (vd->access & SNDRV_CTL_ELEM_ACCESS_INACTIVE)
goto unlock;
vd->access |= SNDRV_CTL_ELEM_ACCESS_INACTIVE;
}
ret = 1;
unlock:
up_write(&card->controls_rwsem);
if (ret > 0)
snd_ctl_notify(card, SNDRV_CTL_EVENT_MASK_INFO, id);
return ret;
}
EXPORT_SYMBOL_GPL(snd_ctl_activate_id);
/**
* snd_ctl_rename_id - replace the id of a control on the card
* @card: the card instance
* @src_id: the old id
* @dst_id: the new id
*
* Finds the control with the old id from the card, and replaces the
* id with the new one.
*
* Returns zero if successful, or a negative error code on failure.
*/
int snd_ctl_rename_id(struct snd_card *card, struct snd_ctl_elem_id *src_id,
struct snd_ctl_elem_id *dst_id)
{
struct snd_kcontrol *kctl;
down_write(&card->controls_rwsem);
kctl = snd_ctl_find_id(card, src_id);
if (kctl == NULL) {
up_write(&card->controls_rwsem);
return -ENOENT;
}
kctl->id = *dst_id;
kctl->id.numid = card->last_numid + 1;
card->last_numid += kctl->count;
up_write(&card->controls_rwsem);
return 0;
}
EXPORT_SYMBOL(snd_ctl_rename_id);
/**
* snd_ctl_find_numid - find the control instance with the given number-id
* @card: the card instance
* @numid: the number-id to search
*
* Finds the control instance with the given number-id from the card.
*
* Returns the pointer of the instance if found, or NULL if not.
*
* The caller must down card->controls_rwsem before calling this function
* (if the race condition can happen).
*/
struct snd_kcontrol *snd_ctl_find_numid(struct snd_card *card, unsigned int numid)
{
struct snd_kcontrol *kctl;
if (snd_BUG_ON(!card || !numid))
return NULL;
list_for_each_entry(kctl, &card->controls, list) {
if (kctl->id.numid <= numid && kctl->id.numid + kctl->count > numid)
return kctl;
}
return NULL;
}
EXPORT_SYMBOL(snd_ctl_find_numid);
/**
* snd_ctl_find_id - find the control instance with the given id
* @card: the card instance
* @id: the id to search
*
* Finds the control instance with the given id from the card.
*
* Returns the pointer of the instance if found, or NULL if not.
*
* The caller must down card->controls_rwsem before calling this function
* (if the race condition can happen).
*/
struct snd_kcontrol *snd_ctl_find_id(struct snd_card *card,
struct snd_ctl_elem_id *id)
{
struct snd_kcontrol *kctl;
if (snd_BUG_ON(!card || !id))
return NULL;
if (id->numid != 0)
return snd_ctl_find_numid(card, id->numid);
list_for_each_entry(kctl, &card->controls, list) {
if (kctl->id.iface != id->iface)
continue;
if (kctl->id.device != id->device)
continue;
if (kctl->id.subdevice != id->subdevice)
continue;
if (strncmp(kctl->id.name, id->name, sizeof(kctl->id.name)))
continue;
if (kctl->id.index > id->index)
continue;
if (kctl->id.index + kctl->count <= id->index)
continue;
return kctl;
}
return NULL;
}
EXPORT_SYMBOL(snd_ctl_find_id);
static int snd_ctl_card_info(struct snd_card *card, struct snd_ctl_file * ctl,
unsigned int cmd, void __user *arg)
{
struct snd_ctl_card_info *info;
info = kzalloc(sizeof(*info), GFP_KERNEL);
if (! info)
return -ENOMEM;
down_read(&snd_ioctl_rwsem);
info->card = card->number;
strlcpy(info->id, card->id, sizeof(info->id));
strlcpy(info->driver, card->driver, sizeof(info->driver));
strlcpy(info->name, card->shortname, sizeof(info->name));
strlcpy(info->longname, card->longname, sizeof(info->longname));
strlcpy(info->mixername, card->mixername, sizeof(info->mixername));
strlcpy(info->components, card->components, sizeof(info->components));
up_read(&snd_ioctl_rwsem);
if (copy_to_user(arg, info, sizeof(struct snd_ctl_card_info))) {
kfree(info);
return -EFAULT;
}
kfree(info);
return 0;
}
static int snd_ctl_elem_list(struct snd_card *card,
struct snd_ctl_elem_list __user *_list)
{
struct list_head *plist;
struct snd_ctl_elem_list list;
struct snd_kcontrol *kctl;
struct snd_ctl_elem_id *dst, *id;
unsigned int offset, space, jidx;
if (copy_from_user(&list, _list, sizeof(list)))
return -EFAULT;
offset = list.offset;
space = list.space;
/* try limit maximum space */
if (space > 16384)
return -ENOMEM;
if (space > 0) {
/* allocate temporary buffer for atomic operation */
dst = vmalloc(space * sizeof(struct snd_ctl_elem_id));
if (dst == NULL)
return -ENOMEM;
down_read(&card->controls_rwsem);
list.count = card->controls_count;
plist = card->controls.next;
while (plist != &card->controls) {
if (offset == 0)
break;
kctl = snd_kcontrol(plist);
if (offset < kctl->count)
break;
offset -= kctl->count;
plist = plist->next;
}
list.used = 0;
id = dst;
while (space > 0 && plist != &card->controls) {
kctl = snd_kcontrol(plist);
for (jidx = offset; space > 0 && jidx < kctl->count; jidx++) {
snd_ctl_build_ioff(id, kctl, jidx);
id++;
space--;
list.used++;
}
plist = plist->next;
offset = 0;
}
up_read(&card->controls_rwsem);
if (list.used > 0 &&
copy_to_user(list.pids, dst,
list.used * sizeof(struct snd_ctl_elem_id))) {
vfree(dst);
return -EFAULT;
}
vfree(dst);
} else {
down_read(&card->controls_rwsem);
list.count = card->controls_count;
up_read(&card->controls_rwsem);
}
if (copy_to_user(_list, &list, sizeof(list)))
return -EFAULT;
return 0;
}
static int snd_ctl_elem_info(struct snd_ctl_file *ctl,
struct snd_ctl_elem_info *info)
{
struct snd_card *card = ctl->card;
struct snd_kcontrol *kctl;
struct snd_kcontrol_volatile *vd;
unsigned int index_offset;
int result;
down_read(&card->controls_rwsem);
kctl = snd_ctl_find_id(card, &info->id);
if (kctl == NULL) {
up_read(&card->controls_rwsem);
return -ENOENT;
}
#ifdef CONFIG_SND_DEBUG
info->access = 0;
#endif
result = kctl->info(kctl, info);
if (result >= 0) {
snd_BUG_ON(info->access);
index_offset = snd_ctl_get_ioff(kctl, &info->id);
vd = &kctl->vd[index_offset];
snd_ctl_build_ioff(&info->id, kctl, index_offset);
info->access = vd->access;
if (vd->owner) {
info->access |= SNDRV_CTL_ELEM_ACCESS_LOCK;
if (vd->owner == ctl)
info->access |= SNDRV_CTL_ELEM_ACCESS_OWNER;
info->owner = pid_vnr(vd->owner->pid);
} else {
info->owner = -1;
}
}
up_read(&card->controls_rwsem);
return result;
}
static int snd_ctl_elem_info_user(struct snd_ctl_file *ctl,
struct snd_ctl_elem_info __user *_info)
{
struct snd_ctl_elem_info info;
int result;
if (copy_from_user(&info, _info, sizeof(info)))
return -EFAULT;
snd_power_lock(ctl->card);
result = snd_power_wait(ctl->card, SNDRV_CTL_POWER_D0);
if (result >= 0)
result = snd_ctl_elem_info(ctl, &info);
snd_power_unlock(ctl->card);
if (result >= 0)
if (copy_to_user(_info, &info, sizeof(info)))
return -EFAULT;
return result;
}
static int snd_ctl_elem_read(struct snd_card *card,
struct snd_ctl_elem_value *control)
{
struct snd_kcontrol *kctl;
struct snd_kcontrol_volatile *vd;
unsigned int index_offset;
int result;
down_read(&card->controls_rwsem);
kctl = snd_ctl_find_id(card, &control->id);
if (kctl == NULL) {
result = -ENOENT;
} else {
index_offset = snd_ctl_get_ioff(kctl, &control->id);
vd = &kctl->vd[index_offset];
if ((vd->access & SNDRV_CTL_ELEM_ACCESS_READ) &&
kctl->get != NULL) {
snd_ctl_build_ioff(&control->id, kctl, index_offset);
result = kctl->get(kctl, control);
} else
result = -EPERM;
}
up_read(&card->controls_rwsem);
return result;
}
static int snd_ctl_elem_read_user(struct snd_card *card,
struct snd_ctl_elem_value __user *_control)
{
struct snd_ctl_elem_value *control;
int result;
control = memdup_user(_control, sizeof(*control));
if (IS_ERR(control))
return PTR_ERR(control);
snd_power_lock(card);
result = snd_power_wait(card, SNDRV_CTL_POWER_D0);
if (result >= 0)
result = snd_ctl_elem_read(card, control);
snd_power_unlock(card);
if (result >= 0)
if (copy_to_user(_control, control, sizeof(*control)))
result = -EFAULT;
kfree(control);
return result;
}
static int snd_ctl_elem_write(struct snd_card *card, struct snd_ctl_file *file,
struct snd_ctl_elem_value *control)
{
struct snd_kcontrol *kctl;
struct snd_kcontrol_volatile *vd;
unsigned int index_offset;
int result;
down_read(&card->controls_rwsem);
kctl = snd_ctl_find_id(card, &control->id);
if (kctl == NULL) {
result = -ENOENT;
} else {
index_offset = snd_ctl_get_ioff(kctl, &control->id);
vd = &kctl->vd[index_offset];
if (!(vd->access & SNDRV_CTL_ELEM_ACCESS_WRITE) ||
kctl->put == NULL ||
(file && vd->owner && vd->owner != file)) {
result = -EPERM;
} else {
snd_ctl_build_ioff(&control->id, kctl, index_offset);
result = kctl->put(kctl, control);
}
if (result > 0) {
struct snd_ctl_elem_id id = control->id;
up_read(&card->controls_rwsem);
snd_ctl_notify(card, SNDRV_CTL_EVENT_MASK_VALUE, &id);
return 0;
}
}
up_read(&card->controls_rwsem);
return result;
}
static int snd_ctl_elem_write_user(struct snd_ctl_file *file,
struct snd_ctl_elem_value __user *_control)
{
struct snd_ctl_elem_value *control;
struct snd_card *card;
int result;
control = memdup_user(_control, sizeof(*control));
if (IS_ERR(control))
return PTR_ERR(control);
card = file->card;
snd_power_lock(card);
result = snd_power_wait(card, SNDRV_CTL_POWER_D0);
if (result >= 0)
result = snd_ctl_elem_write(card, file, control);
snd_power_unlock(card);
if (result >= 0)
if (copy_to_user(_control, control, sizeof(*control)))
result = -EFAULT;
kfree(control);
return result;
}
static int snd_ctl_elem_lock(struct snd_ctl_file *file,
struct snd_ctl_elem_id __user *_id)
{
struct snd_card *card = file->card;
struct snd_ctl_elem_id id;
struct snd_kcontrol *kctl;
struct snd_kcontrol_volatile *vd;
int result;
if (copy_from_user(&id, _id, sizeof(id)))
return -EFAULT;
down_write(&card->controls_rwsem);
kctl = snd_ctl_find_id(card, &id);
if (kctl == NULL) {
result = -ENOENT;
} else {
vd = &kctl->vd[snd_ctl_get_ioff(kctl, &id)];
if (vd->owner != NULL)
result = -EBUSY;
else {
vd->owner = file;
result = 0;
}
}
up_write(&card->controls_rwsem);
return result;
}
static int snd_ctl_elem_unlock(struct snd_ctl_file *file,
struct snd_ctl_elem_id __user *_id)
{
struct snd_card *card = file->card;
struct snd_ctl_elem_id id;
struct snd_kcontrol *kctl;
struct snd_kcontrol_volatile *vd;
int result;
if (copy_from_user(&id, _id, sizeof(id)))
return -EFAULT;
down_write(&card->controls_rwsem);
kctl = snd_ctl_find_id(card, &id);
if (kctl == NULL) {
result = -ENOENT;
} else {
vd = &kctl->vd[snd_ctl_get_ioff(kctl, &id)];
if (vd->owner == NULL)
result = -EINVAL;
else if (vd->owner != file)
result = -EPERM;
else {
vd->owner = NULL;
result = 0;
}
}
up_write(&card->controls_rwsem);
return result;
}
struct user_element {
struct snd_ctl_elem_info info;
struct snd_card *card;
void *elem_data; /* element data */
unsigned long elem_data_size; /* size of element data in bytes */
void *tlv_data; /* TLV data */
unsigned long tlv_data_size; /* TLV data size */
void *priv_data; /* private data (like strings for enumerated type) */
};
static int snd_ctl_elem_user_info(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_info *uinfo)
{
struct user_element *ue = kcontrol->private_data;
*uinfo = ue->info;
return 0;
}
static int snd_ctl_elem_user_enum_info(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_info *uinfo)
{
struct user_element *ue = kcontrol->private_data;
const char *names;
unsigned int item;
item = uinfo->value.enumerated.item;
*uinfo = ue->info;
item = min(item, uinfo->value.enumerated.items - 1);
uinfo->value.enumerated.item = item;
names = ue->priv_data;
for (; item > 0; --item)
names += strlen(names) + 1;
strcpy(uinfo->value.enumerated.name, names);
return 0;
}
static int snd_ctl_elem_user_get(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol)
{
struct user_element *ue = kcontrol->private_data;
mutex_lock(&ue->card->user_ctl_lock);
memcpy(&ucontrol->value, ue->elem_data, ue->elem_data_size);
mutex_unlock(&ue->card->user_ctl_lock);
return 0;
}
static int snd_ctl_elem_user_put(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol)
{
int change;
struct user_element *ue = kcontrol->private_data;
mutex_lock(&ue->card->user_ctl_lock);
change = memcmp(&ucontrol->value, ue->elem_data, ue->elem_data_size) != 0;
if (change)
memcpy(ue->elem_data, &ucontrol->value, ue->elem_data_size);
mutex_unlock(&ue->card->user_ctl_lock);
return change;
}
static int snd_ctl_elem_user_tlv(struct snd_kcontrol *kcontrol,
int op_flag,
unsigned int size,
unsigned int __user *tlv)
{
struct user_element *ue = kcontrol->private_data;
int change = 0;
void *new_data;
if (op_flag > 0) {
if (size > 1024 * 128) /* sane value */
return -EINVAL;
new_data = memdup_user(tlv, size);
if (IS_ERR(new_data))
return PTR_ERR(new_data);
mutex_lock(&ue->card->user_ctl_lock);
change = ue->tlv_data_size != size;
if (!change)
change = memcmp(ue->tlv_data, new_data, size);
kfree(ue->tlv_data);
ue->tlv_data = new_data;
ue->tlv_data_size = size;
mutex_unlock(&ue->card->user_ctl_lock);
} else {
int ret = 0;
mutex_lock(&ue->card->user_ctl_lock);
if (!ue->tlv_data_size || !ue->tlv_data) {
ret = -ENXIO;
goto err_unlock;
}
if (size < ue->tlv_data_size) {
ret = -ENOSPC;
goto err_unlock;
}
if (copy_to_user(tlv, ue->tlv_data, ue->tlv_data_size))
ret = -EFAULT;
err_unlock:
mutex_unlock(&ue->card->user_ctl_lock);
if (ret)
return ret;
}
return change;
}
static int snd_ctl_elem_init_enum_names(struct user_element *ue)
{
char *names, *p;
size_t buf_len, name_len;
unsigned int i;
const uintptr_t user_ptrval = ue->info.value.enumerated.names_ptr;
if (ue->info.value.enumerated.names_length > 64 * 1024)
return -EINVAL;
names = memdup_user((const void __user *)user_ptrval,
ue->info.value.enumerated.names_length);
if (IS_ERR(names))
return PTR_ERR(names);
/* check that there are enough valid names */
buf_len = ue->info.value.enumerated.names_length;
p = names;
for (i = 0; i < ue->info.value.enumerated.items; ++i) {
name_len = strnlen(p, buf_len);
if (name_len == 0 || name_len >= 64 || name_len == buf_len) {
kfree(names);
return -EINVAL;
}
p += name_len + 1;
buf_len -= name_len + 1;
}
ue->priv_data = names;
ue->info.value.enumerated.names_ptr = 0;
return 0;
}
static void snd_ctl_elem_user_free(struct snd_kcontrol *kcontrol)
{
struct user_element *ue = kcontrol->private_data;
kfree(ue->tlv_data);
kfree(ue->priv_data);
kfree(ue);
}
static int snd_ctl_elem_add(struct snd_ctl_file *file,
struct snd_ctl_elem_info *info, int replace)
{
struct snd_card *card = file->card;
struct snd_kcontrol kctl, *_kctl;
unsigned int access;
long private_size;
struct user_element *ue;
int idx, err;
if (info->count < 1)
return -EINVAL;
access = info->access == 0 ? SNDRV_CTL_ELEM_ACCESS_READWRITE :
(info->access & (SNDRV_CTL_ELEM_ACCESS_READWRITE|
SNDRV_CTL_ELEM_ACCESS_INACTIVE|
SNDRV_CTL_ELEM_ACCESS_TLV_READWRITE));
info->id.numid = 0;
memset(&kctl, 0, sizeof(kctl));
if (replace) {
err = snd_ctl_remove_user_ctl(file, &info->id);
if (err)
return err;
}
if (card->user_ctl_count >= MAX_USER_CONTROLS)
return -ENOMEM;
memcpy(&kctl.id, &info->id, sizeof(info->id));
kctl.count = info->owner ? info->owner : 1;
access |= SNDRV_CTL_ELEM_ACCESS_USER;
if (info->type == SNDRV_CTL_ELEM_TYPE_ENUMERATED)
kctl.info = snd_ctl_elem_user_enum_info;
else
kctl.info = snd_ctl_elem_user_info;
if (access & SNDRV_CTL_ELEM_ACCESS_READ)
kctl.get = snd_ctl_elem_user_get;
if (access & SNDRV_CTL_ELEM_ACCESS_WRITE)
kctl.put = snd_ctl_elem_user_put;
if (access & SNDRV_CTL_ELEM_ACCESS_TLV_READWRITE) {
kctl.tlv.c = snd_ctl_elem_user_tlv;
access |= SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK;
}
switch (info->type) {
case SNDRV_CTL_ELEM_TYPE_BOOLEAN:
case SNDRV_CTL_ELEM_TYPE_INTEGER:
private_size = sizeof(long);
if (info->count > 128)
return -EINVAL;
break;
case SNDRV_CTL_ELEM_TYPE_INTEGER64:
private_size = sizeof(long long);
if (info->count > 64)
return -EINVAL;
break;
case SNDRV_CTL_ELEM_TYPE_ENUMERATED:
private_size = sizeof(unsigned int);
if (info->count > 128 || info->value.enumerated.items == 0)
return -EINVAL;
break;
case SNDRV_CTL_ELEM_TYPE_BYTES:
private_size = sizeof(unsigned char);
if (info->count > 512)
return -EINVAL;
break;
case SNDRV_CTL_ELEM_TYPE_IEC958:
private_size = sizeof(struct snd_aes_iec958);
if (info->count != 1)
return -EINVAL;
break;
default:
return -EINVAL;
}
private_size *= info->count;
ue = kzalloc(sizeof(struct user_element) + private_size, GFP_KERNEL);
if (ue == NULL)
return -ENOMEM;
ue->card = card;
ue->info = *info;
ue->info.access = 0;
ue->elem_data = (char *)ue + sizeof(*ue);
ue->elem_data_size = private_size;
if (ue->info.type == SNDRV_CTL_ELEM_TYPE_ENUMERATED) {
err = snd_ctl_elem_init_enum_names(ue);
if (err < 0) {
kfree(ue);
return err;
}
}
kctl.private_free = snd_ctl_elem_user_free;
_kctl = snd_ctl_new(&kctl, access);
if (_kctl == NULL) {
kfree(ue->priv_data);
kfree(ue);
return -ENOMEM;
}
_kctl->private_data = ue;
for (idx = 0; idx < _kctl->count; idx++)
_kctl->vd[idx].owner = file;
err = snd_ctl_add(card, _kctl);
if (err < 0)
return err;
down_write(&card->controls_rwsem);
card->user_ctl_count++;
up_write(&card->controls_rwsem);
return 0;
}
static int snd_ctl_elem_add_user(struct snd_ctl_file *file,
struct snd_ctl_elem_info __user *_info, int replace)
{
struct snd_ctl_elem_info info;
if (copy_from_user(&info, _info, sizeof(info)))
return -EFAULT;
return snd_ctl_elem_add(file, &info, replace);
}
static int snd_ctl_elem_remove(struct snd_ctl_file *file,
struct snd_ctl_elem_id __user *_id)
{
struct snd_ctl_elem_id id;
if (copy_from_user(&id, _id, sizeof(id)))
return -EFAULT;
return snd_ctl_remove_user_ctl(file, &id);
}
static int snd_ctl_subscribe_events(struct snd_ctl_file *file, int __user *ptr)
{
int subscribe;
if (get_user(subscribe, ptr))
return -EFAULT;
if (subscribe < 0) {
subscribe = file->subscribed;
if (put_user(subscribe, ptr))
return -EFAULT;
return 0;
}
if (subscribe) {
file->subscribed = 1;
return 0;
} else if (file->subscribed) {
snd_ctl_empty_read_queue(file);
file->subscribed = 0;
}
return 0;
}
static int snd_ctl_tlv_ioctl(struct snd_ctl_file *file,
struct snd_ctl_tlv __user *_tlv,
int op_flag)
{
struct snd_card *card = file->card;
struct snd_ctl_tlv tlv;
struct snd_kcontrol *kctl;
struct snd_kcontrol_volatile *vd;
unsigned int len;
int err = 0;
if (copy_from_user(&tlv, _tlv, sizeof(tlv)))
return -EFAULT;
if (tlv.length < sizeof(unsigned int) * 2)
return -EINVAL;
down_read(&card->controls_rwsem);
kctl = snd_ctl_find_numid(card, tlv.numid);
if (kctl == NULL) {
err = -ENOENT;
goto __kctl_end;
}
if (kctl->tlv.p == NULL) {
err = -ENXIO;
goto __kctl_end;
}
vd = &kctl->vd[tlv.numid - kctl->id.numid];
if ((op_flag == 0 && (vd->access & SNDRV_CTL_ELEM_ACCESS_TLV_READ) == 0) ||
(op_flag > 0 && (vd->access & SNDRV_CTL_ELEM_ACCESS_TLV_WRITE) == 0) ||
(op_flag < 0 && (vd->access & SNDRV_CTL_ELEM_ACCESS_TLV_COMMAND) == 0)) {
err = -ENXIO;
goto __kctl_end;
}
if (vd->access & SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK) {
if (vd->owner != NULL && vd->owner != file) {
err = -EPERM;
goto __kctl_end;
}
err = kctl->tlv.c(kctl, op_flag, tlv.length, _tlv->tlv);
if (err > 0) {
struct snd_ctl_elem_id id = kctl->id;
up_read(&card->controls_rwsem);
snd_ctl_notify(card, SNDRV_CTL_EVENT_MASK_TLV, &id);
return 0;
}
} else {
if (op_flag) {
err = -ENXIO;
goto __kctl_end;
}
len = kctl->tlv.p[1] + 2 * sizeof(unsigned int);
if (tlv.length < len) {
err = -ENOMEM;
goto __kctl_end;
}
if (copy_to_user(_tlv->tlv, kctl->tlv.p, len))
err = -EFAULT;
}
__kctl_end:
up_read(&card->controls_rwsem);
return err;
}
static long snd_ctl_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
{
struct snd_ctl_file *ctl;
struct snd_card *card;
struct snd_kctl_ioctl *p;
void __user *argp = (void __user *)arg;
int __user *ip = argp;
int err;
ctl = file->private_data;
card = ctl->card;
if (snd_BUG_ON(!card))
return -ENXIO;
switch (cmd) {
case SNDRV_CTL_IOCTL_PVERSION:
return put_user(SNDRV_CTL_VERSION, ip) ? -EFAULT : 0;
case SNDRV_CTL_IOCTL_CARD_INFO:
return snd_ctl_card_info(card, ctl, cmd, argp);
case SNDRV_CTL_IOCTL_ELEM_LIST:
return snd_ctl_elem_list(card, argp);
case SNDRV_CTL_IOCTL_ELEM_INFO:
return snd_ctl_elem_info_user(ctl, argp);
case SNDRV_CTL_IOCTL_ELEM_READ:
return snd_ctl_elem_read_user(card, argp);
case SNDRV_CTL_IOCTL_ELEM_WRITE:
return snd_ctl_elem_write_user(ctl, argp);
case SNDRV_CTL_IOCTL_ELEM_LOCK:
return snd_ctl_elem_lock(ctl, argp);
case SNDRV_CTL_IOCTL_ELEM_UNLOCK:
return snd_ctl_elem_unlock(ctl, argp);
case SNDRV_CTL_IOCTL_ELEM_ADD:
return snd_ctl_elem_add_user(ctl, argp, 0);
case SNDRV_CTL_IOCTL_ELEM_REPLACE:
return snd_ctl_elem_add_user(ctl, argp, 1);
case SNDRV_CTL_IOCTL_ELEM_REMOVE:
return snd_ctl_elem_remove(ctl, argp);
case SNDRV_CTL_IOCTL_SUBSCRIBE_EVENTS:
return snd_ctl_subscribe_events(ctl, ip);
case SNDRV_CTL_IOCTL_TLV_READ:
return snd_ctl_tlv_ioctl(ctl, argp, 0);
case SNDRV_CTL_IOCTL_TLV_WRITE:
return snd_ctl_tlv_ioctl(ctl, argp, 1);
case SNDRV_CTL_IOCTL_TLV_COMMAND:
return snd_ctl_tlv_ioctl(ctl, argp, -1);
case SNDRV_CTL_IOCTL_POWER:
return -ENOPROTOOPT;
case SNDRV_CTL_IOCTL_POWER_STATE:
#ifdef CONFIG_PM
return put_user(card->power_state, ip) ? -EFAULT : 0;
#else
return put_user(SNDRV_CTL_POWER_D0, ip) ? -EFAULT : 0;
#endif
}
down_read(&snd_ioctl_rwsem);
list_for_each_entry(p, &snd_control_ioctls, list) {
err = p->fioctl(card, ctl, cmd, arg);
if (err != -ENOIOCTLCMD) {
up_read(&snd_ioctl_rwsem);
return err;
}
}
up_read(&snd_ioctl_rwsem);
snd_printdd("unknown ioctl = 0x%x\n", cmd);
return -ENOTTY;
}
static ssize_t snd_ctl_read(struct file *file, char __user *buffer,
size_t count, loff_t * offset)
{
struct snd_ctl_file *ctl;
int err = 0;
ssize_t result = 0;
ctl = file->private_data;
if (snd_BUG_ON(!ctl || !ctl->card))
return -ENXIO;
if (!ctl->subscribed)
return -EBADFD;
if (count < sizeof(struct snd_ctl_event))
return -EINVAL;
spin_lock_irq(&ctl->read_lock);
while (count >= sizeof(struct snd_ctl_event)) {
struct snd_ctl_event ev;
struct snd_kctl_event *kev;
while (list_empty(&ctl->events)) {
wait_queue_t wait;
if ((file->f_flags & O_NONBLOCK) != 0 || result > 0) {
err = -EAGAIN;
goto __end_lock;
}
init_waitqueue_entry(&wait, current);
add_wait_queue(&ctl->change_sleep, &wait);
set_current_state(TASK_INTERRUPTIBLE);
spin_unlock_irq(&ctl->read_lock);
schedule();
remove_wait_queue(&ctl->change_sleep, &wait);
if (ctl->card->shutdown)
return -ENODEV;
if (signal_pending(current))
return -ERESTARTSYS;
spin_lock_irq(&ctl->read_lock);
}
kev = snd_kctl_event(ctl->events.next);
ev.type = SNDRV_CTL_EVENT_ELEM;
ev.data.elem.mask = kev->mask;
ev.data.elem.id = kev->id;
list_del(&kev->list);
spin_unlock_irq(&ctl->read_lock);
kfree(kev);
if (copy_to_user(buffer, &ev, sizeof(struct snd_ctl_event))) {
err = -EFAULT;
goto __end;
}
spin_lock_irq(&ctl->read_lock);
buffer += sizeof(struct snd_ctl_event);
count -= sizeof(struct snd_ctl_event);
result += sizeof(struct snd_ctl_event);
}
__end_lock:
spin_unlock_irq(&ctl->read_lock);
__end:
return result > 0 ? result : err;
}
static unsigned int snd_ctl_poll(struct file *file, poll_table * wait)
{
unsigned int mask;
struct snd_ctl_file *ctl;
ctl = file->private_data;
if (!ctl->subscribed)
return 0;
poll_wait(file, &ctl->change_sleep, wait);
mask = 0;
if (!list_empty(&ctl->events))
mask |= POLLIN | POLLRDNORM;
return mask;
}
/*
* register the device-specific control-ioctls.
* called from each device manager like pcm.c, hwdep.c, etc.
*/
static int _snd_ctl_register_ioctl(snd_kctl_ioctl_func_t fcn, struct list_head *lists)
{
struct snd_kctl_ioctl *pn;
pn = kzalloc(sizeof(struct snd_kctl_ioctl), GFP_KERNEL);
if (pn == NULL)
return -ENOMEM;
pn->fioctl = fcn;
down_write(&snd_ioctl_rwsem);
list_add_tail(&pn->list, lists);
up_write(&snd_ioctl_rwsem);
return 0;
}
int snd_ctl_register_ioctl(snd_kctl_ioctl_func_t fcn)
{
return _snd_ctl_register_ioctl(fcn, &snd_control_ioctls);
}
EXPORT_SYMBOL(snd_ctl_register_ioctl);
#ifdef CONFIG_COMPAT
int snd_ctl_register_ioctl_compat(snd_kctl_ioctl_func_t fcn)
{
return _snd_ctl_register_ioctl(fcn, &snd_control_compat_ioctls);
}
EXPORT_SYMBOL(snd_ctl_register_ioctl_compat);
#endif
/*
* de-register the device-specific control-ioctls.
*/
static int _snd_ctl_unregister_ioctl(snd_kctl_ioctl_func_t fcn,
struct list_head *lists)
{
struct snd_kctl_ioctl *p;
if (snd_BUG_ON(!fcn))
return -EINVAL;
down_write(&snd_ioctl_rwsem);
list_for_each_entry(p, lists, list) {
if (p->fioctl == fcn) {
list_del(&p->list);
up_write(&snd_ioctl_rwsem);
kfree(p);
return 0;
}
}
up_write(&snd_ioctl_rwsem);
snd_BUG();
return -EINVAL;
}
int snd_ctl_unregister_ioctl(snd_kctl_ioctl_func_t fcn)
{
return _snd_ctl_unregister_ioctl(fcn, &snd_control_ioctls);
}
EXPORT_SYMBOL(snd_ctl_unregister_ioctl);
#ifdef CONFIG_COMPAT
int snd_ctl_unregister_ioctl_compat(snd_kctl_ioctl_func_t fcn)
{
return _snd_ctl_unregister_ioctl(fcn, &snd_control_compat_ioctls);
}
EXPORT_SYMBOL(snd_ctl_unregister_ioctl_compat);
#endif
static int snd_ctl_fasync(int fd, struct file * file, int on)
{
struct snd_ctl_file *ctl;
ctl = file->private_data;
return fasync_helper(fd, file, on, &ctl->fasync);
}
/*
* ioctl32 compat
*/
#ifdef CONFIG_COMPAT
#include "control_compat.c"
#else
#define snd_ctl_ioctl_compat NULL
#endif
/*
* INIT PART
*/
static const struct file_operations snd_ctl_f_ops =
{
.owner = THIS_MODULE,
.read = snd_ctl_read,
.open = snd_ctl_open,
.release = snd_ctl_release,
.llseek = no_llseek,
.poll = snd_ctl_poll,
.unlocked_ioctl = snd_ctl_ioctl,
.compat_ioctl = snd_ctl_ioctl_compat,
.fasync = snd_ctl_fasync,
};
/*
* registration of the control device
*/
static int snd_ctl_dev_register(struct snd_device *device)
{
struct snd_card *card = device->device_data;
int err, cardnum;
char name[16];
if (snd_BUG_ON(!card))
return -ENXIO;
cardnum = card->number;
if (snd_BUG_ON(cardnum < 0 || cardnum >= SNDRV_CARDS))
return -ENXIO;
sprintf(name, "controlC%i", cardnum);
if ((err = snd_register_device(SNDRV_DEVICE_TYPE_CONTROL, card, -1,
&snd_ctl_f_ops, card, name)) < 0)
return err;
return 0;
}
/*
* disconnection of the control device
*/
static int snd_ctl_dev_disconnect(struct snd_device *device)
{
struct snd_card *card = device->device_data;
struct snd_ctl_file *ctl;
int err, cardnum;
if (snd_BUG_ON(!card))
return -ENXIO;
cardnum = card->number;
if (snd_BUG_ON(cardnum < 0 || cardnum >= SNDRV_CARDS))
return -ENXIO;
read_lock(&card->ctl_files_rwlock);
list_for_each_entry(ctl, &card->ctl_files, list) {
wake_up(&ctl->change_sleep);
kill_fasync(&ctl->fasync, SIGIO, POLL_ERR);
}
read_unlock(&card->ctl_files_rwlock);
if ((err = snd_unregister_device(SNDRV_DEVICE_TYPE_CONTROL,
card, -1)) < 0)
return err;
return 0;
}
/*
* free all controls
*/
static int snd_ctl_dev_free(struct snd_device *device)
{
struct snd_card *card = device->device_data;
struct snd_kcontrol *control;
down_write(&card->controls_rwsem);
while (!list_empty(&card->controls)) {
control = snd_kcontrol(card->controls.next);
snd_ctl_remove(card, control);
}
up_write(&card->controls_rwsem);
return 0;
}
/*
* create control core:
* called from init.c
*/
int snd_ctl_create(struct snd_card *card)
{
static struct snd_device_ops ops = {
.dev_free = snd_ctl_dev_free,
.dev_register = snd_ctl_dev_register,
.dev_disconnect = snd_ctl_dev_disconnect,
};
if (snd_BUG_ON(!card))
return -ENXIO;
return snd_device_new(card, SNDRV_DEV_CONTROL, card, &ops);
}
/*
* Frequently used control callbacks/helpers
*/
int snd_ctl_boolean_mono_info(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_info *uinfo)
{
uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN;
uinfo->count = 1;
uinfo->value.integer.min = 0;
uinfo->value.integer.max = 1;
return 0;
}
EXPORT_SYMBOL(snd_ctl_boolean_mono_info);
int snd_ctl_boolean_stereo_info(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_info *uinfo)
{
uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN;
uinfo->count = 2;
uinfo->value.integer.min = 0;
uinfo->value.integer.max = 1;
return 0;
}
EXPORT_SYMBOL(snd_ctl_boolean_stereo_info);
/**
* snd_ctl_enum_info - fills the info structure for an enumerated control
* @info: the structure to be filled
* @channels: the number of the control's channels; often one
* @items: the number of control values; also the size of @names
* @names: an array containing the names of all control values
*
* Sets all required fields in @info to their appropriate values.
* If the control's accessibility is not the default (readable and writable),
* the caller has to fill @info->access.
*/
int snd_ctl_enum_info(struct snd_ctl_elem_info *info, unsigned int channels,
unsigned int items, const char *const names[])
{
info->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
info->count = channels;
info->value.enumerated.items = items;
if (info->value.enumerated.item >= items)
info->value.enumerated.item = items - 1;
strlcpy(info->value.enumerated.name,
names[info->value.enumerated.item],
sizeof(info->value.enumerated.name));
return 0;
}
EXPORT_SYMBOL(snd_ctl_enum_info);
| civato/P900-Lollipop | sound/core/control.c | C | gpl-2.0 | 45,796 | [
30522,
1013,
1008,
1008,
23964,
2005,
4062,
2491,
8278,
1008,
9385,
1006,
1039,
1007,
2011,
15723,
23085,
18712,
11246,
2050,
1026,
23976,
2595,
1030,
23976,
2595,
1012,
1039,
2480,
1028,
1008,
1008,
1008,
2023,
2565,
2003,
2489,
4007,
1025... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
# Load the rails application
require File.expand_path('../application', __FILE__)
# Initialize the rails application
RailsFrance::Application.initialize!
| nicolasleger/railsfrance.org | config/environment.rb | Ruby | agpl-3.0 | 155 | [
30522,
1001,
7170,
1996,
15168,
4646,
5478,
5371,
1012,
7818,
1035,
4130,
1006,
1005,
1012,
1012,
1013,
4646,
1005,
1010,
1035,
1035,
5371,
1035,
1035,
1007,
1001,
3988,
4697,
1996,
15168,
4646,
15168,
27843,
5897,
1024,
1024,
4646,
1012,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
## Close
### What is the value of the first triangle number to have over five hundred divisors?
print max([len(m) for m in map(lambda k: [n for n in range(1,(k+1)) if k%n == 0], [sum(range(n)) for n in range(1,1000)])]) | jacksarick/My-Code | Python/python challenges/euler/012_divisable_tri_nums.py | Python | mit | 219 | [
30522,
1001,
1001,
2485,
1001,
1001,
1001,
2054,
2003,
1996,
3643,
1997,
1996,
2034,
9546,
2193,
2000,
2031,
2058,
2274,
3634,
4487,
11365,
5668,
1029,
6140,
4098,
1006,
1031,
18798,
1006,
1049,
1007,
2005,
1049,
1999,
4949,
1006,
23375,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
#!/usr/bin/python
import pygeoip
import json
from logsparser.lognormalizer import LogNormalizer as LN
import gzip
import glob
import socket
import urllib2
IP = 'IP.Of,Your.Server'
normalizer = LN('/usr/local/share/logsparser/normalizers')
gi = pygeoip.GeoIP('../GeoLiteCity.dat')
def complete(text, state):
return (glob.glob(text+'*')+[none])[state]
def sshcheck():
attacks = {}
users = {}
try:
import readline, rlcompleter
readline.set_completer_delims(' \t\n;')
readline.parse_and_bind("tab: complete")
readline.set_completer(complete)
except ImportError:
print 'No Tab Completion'
LOGs = raw_input('Enter the path to the log file: ')
for LOG in LOGs.split(' '):
if LOG.endswith('.gz'):
auth_logs = gzip.GzipFile(LOG, 'r')
else:
auth_logs = open(LOG, 'r')
if len(LOGs) is '1':
print "Parsing log file"
else:
print "Parsing log files"
for log in auth_logs:
l = {"raw": log }
normalizer.normalize(l)
if l.get('action') == 'fail' and l.get('program') == 'sshd':
u = l['user']
p = l['source_ip']
o1, o2, o3, o4 = [int(i) for i in p.split('.')]
if o1 == 192 and o2 == 168 or o1 == 172 and o2 in range(16, 32) or o1 == 10:
print "Private IP, %s No geolocation data" %str(p)
attacks[p] = attacks.get(p, 0) + 1
getip()
dojson(attacks, IP)
def getip():
global IP
if IP is 0:
try:
i = urllib2.Request("http://icanhazip.com")
p = urllib2.urlopen(i)
IP = p.read()
except:
print "can't seem to grab your IP please set IP variable so We can better map attacks"
def dojson(attacks, IP):
data = {}
for i,(a,p) in enumerate(attacks.iteritems()):
datalist = [{ 'ip': a, 'attacks': p, 'local_ip': IP }]
data[i] = datalist
newdata = data
newjson = json.dumps(newdata)
print json.loads(newjson)
send(newjson)
def send(data):
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect(('Ip.Of.Your.Server', 9999))
s.sendall(data)
s.close()
try:
sshcheck()
except KeyboardInterrupt:
print '\nCtrl+C Exiting...'
exit(0)
| radman404/Who-s-attacking-me-now-- | wamnclient.py | Python | gpl-2.0 | 2,126 | [
30522,
1001,
999,
1013,
2149,
2099,
1013,
8026,
1013,
18750,
12324,
1052,
2100,
3351,
10448,
2361,
12324,
1046,
3385,
2013,
15664,
19362,
8043,
1012,
8833,
12131,
9067,
17629,
12324,
8833,
12131,
9067,
17629,
2004,
1048,
2078,
12324,
1043,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
# Azure Container Instances
<IMG SRC="https://azbotstorage.blob.core.windows.net/badges/201-aci-linuxcontainer-volume-emptydir/PublicLastTestDate.svg" />
<IMG SRC="https://azbotstorage.blob.core.windows.net/badges/201-aci-linuxcontainer-volume-emptydir/PublicDeployment.svg" />
<IMG SRC="https://azbotstorage.blob.core.windows.net/badges/201-aci-linuxcontainer-volume-emptydir/FairfaxLastTestDate.svg" />
<IMG SRC="https://azbotstorage.blob.core.windows.net/badges/201-aci-linuxcontainer-volume-emptydir/FairfaxDeployment.svg" />
<IMG SRC="https://azbotstorage.blob.core.windows.net/badges/201-aci-linuxcontainer-volume-emptydir/BestPracticeResult.svg" />
<IMG SRC="https://azbotstorage.blob.core.windows.net/badges/201-aci-linuxcontainer-volume-emptydir/CredScanResult.svg" />
<a href="https://portal.azure.com/#create/Microsoft.Template/uri/https%3A%2F%2Fraw.githubusercontent.com%2FAzure%2Fazure-quickstart-templates%2Fmaster%2F201-aci-linuxcontainer-volume-emptydir%2Fazuredeploy.json" target="_blank">
<img src="https://raw.githubusercontent.com/Azure/azure-quickstart-templates/master/1-CONTRIBUTION-GUIDE/images/deploytoazure.png"/>
</a>
<a href="http://armviz.io/#/?load=https%3A%2F%2Fraw.githubusercontent.com%2FAzure%2Fazure-quickstart-templates%2Fmaster%2F201-aci-linuxcontainer-volume-emptydir%2Fazuredeploy.json" target="_blank">
<img src="https://raw.githubusercontent.com/Azure/azure-quickstart-templates/master/1-CONTRIBUTION-GUIDE/images/visualizebutton.png"/>
</a>
This template demonstrates a simple use case for emptyDir volume of [Azure Container Instances](https://docs.microsoft.com/en-us/azure/container-instances/).
| robotechredmond/azure-quickstart-templates | 201-aci-linuxcontainer-volume-emptydir/README.md | Markdown | mit | 1,690 | [
30522,
1001,
24296,
11661,
12107,
1026,
10047,
2290,
5034,
2278,
1027,
1000,
16770,
1024,
1013,
1013,
17207,
27014,
4263,
4270,
1012,
1038,
4135,
2497,
1012,
4563,
1012,
3645,
1012,
5658,
1013,
23433,
1013,
16345,
1011,
9353,
2072,
1011,
11... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
package org.opencommercesearch.client.impl;
import java.util.Date;
/**
* Represents a sku's availability.
*
* @author rmerizalde
*/
public class Availability {
public enum Status {
InStock,
OutOfStock,
PermanentlyOutOfStock,
Backorderable,
Preorderable
}
private Status status;
private Long stockLevel;
private Long backorderLevel;
private Date date;
public Date getDate() {
return date;
}
public void setDate(Date date) {
this.date = date;
}
public Status getStatus() {
return status;
}
public void setStatus(Status status) {
this.status = status;
}
public Long getStockLevel() {
return stockLevel;
}
public void setStockLevel(Long stockLevel) {
this.stockLevel = stockLevel;
}
public Long getBackorderLevel() {
return backorderLevel;
}
public void setBackorderLevel(Long backorderLevel) {
this.backorderLevel = backorderLevel;
}
}
| madickson/opencommercesearch | opencommercesearch-sdk-java/src/main/java/org/opencommercesearch/client/impl/Availability.java | Java | apache-2.0 | 947 | [
30522,
7427,
8917,
1012,
2330,
9006,
5017,
9623,
14644,
2818,
1012,
7396,
1012,
17727,
2140,
1025,
12324,
9262,
1012,
21183,
4014,
1012,
3058,
1025,
1013,
1008,
1008,
1008,
5836,
1037,
15315,
2226,
1005,
1055,
11343,
1012,
1008,
1008,
1030,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
package yokohama.unit.ast;
public abstract class AstVisitor<T> {
public abstract T visitGroup(Group group);
public abstract T visitAbbreviation(Abbreviation abbreviation);
public T visitDefinition(Definition definition) {
return definition.accept(
this::visitTest,
this::visitFourPhaseTest,
this::visitTable,
this::visitCodeBlock,
this::visitHeading);
}
public abstract T visitTest(Test test);
public abstract T visitAssertion(Assertion assertion);
public abstract T visitClause(Clause clause);
public abstract T visitProposition(Proposition proposition);
public T visitPredicate(Predicate predicate) {
return predicate.accept(
this::visitIsPredicate,
this::visitIsNotPredicate,
this::visitThrowsPredicate,
this::visitMatchesPredicate,
this::visitDoesNotMatchPredicate);
};
public abstract T visitIsPredicate(IsPredicate isPredicate);
public abstract T visitIsNotPredicate(IsNotPredicate isNotPredicate);
public abstract T visitThrowsPredicate(ThrowsPredicate throwsPredicate);
public abstract T visitMatchesPredicate(MatchesPredicate matchesPredicate);
public abstract T visitDoesNotMatchPredicate(DoesNotMatchPredicate doesNotMatchPredicate);
public T visitMatcher(Matcher matcher) {
return matcher.accept(
this::visitEqualToMatcher,
this::visitInstanceOfMatcher,
this::visitInstanceSuchThatMatcher,
this::visitNullValueMatcher);
}
public abstract T visitEqualToMatcher(EqualToMatcher equalTo);
public abstract T visitInstanceOfMatcher(InstanceOfMatcher instanceOf);
public abstract T visitInstanceSuchThatMatcher(InstanceSuchThatMatcher instanceSuchThat);
public abstract T visitNullValueMatcher(NullValueMatcher nullValue);
public T visitPattern(Pattern pattern) {
return pattern.accept((java.util.function.Function<RegExpPattern, T>)(this::visitRegExpPattern));
}
public abstract T visitRegExpPattern(RegExpPattern regExpPattern);
public T visitExpr(Expr expr) {
return expr.accept(
this::visitQuotedExpr,
this::visitStubExpr,
this::visitInvocationExpr,
this::visitIntegerExpr,
this::visitFloatingPointExpr,
this::visitBooleanExpr,
this::visitCharExpr,
this::visitStringExpr,
this::visitAnchorExpr,
this::visitAsExpr,
this::visitResourceExpr,
this::visitTempFileExpr);
}
public abstract T visitQuotedExpr(QuotedExpr quotedExpr);
public abstract T visitStubExpr(StubExpr stubExpr);
public abstract T visitInvocationExpr(InvocationExpr invocationExpr);
public abstract T visitIntegerExpr(IntegerExpr integerExpr);
public abstract T visitFloatingPointExpr(FloatingPointExpr floatingPointExpr);
public abstract T visitBooleanExpr(BooleanExpr booleanExpr);
public abstract T visitCharExpr(CharExpr charExpr);
public abstract T visitStringExpr(StringExpr stringExpr);
public abstract T visitAnchorExpr(AnchorExpr anchorExpr);
public abstract T visitAsExpr(AsExpr asExpr);
public abstract T visitResourceExpr(ResourceExpr resourceExpr);
public abstract T visitTempFileExpr(TempFileExpr tempFileExpr);
public T visitStubBehavior(StubBehavior behavior) {
return behavior.accept(
this::visitStubReturns,
this::visitStubThrows);
}
public abstract T visitStubReturns(StubReturns stubReturns);
public abstract T visitStubThrows(StubThrows stubThrows);
public abstract T visitMethodPattern(MethodPattern methodPattern);
public abstract T visitType(Type type);
public T visitNonArrayType(NonArrayType nonArrayType) {
return nonArrayType.accept(
this::visitPrimitiveType,
this::visitClassType);
}
public abstract T visitPrimitiveType(PrimitiveType primitiveType);
public abstract T visitClassType(ClassType classType);
public T visitFixture(Fixture fixture) {
return fixture.accept(
this::visitNone,
this::visitTableRef,
this::visitBindings);
}
public abstract T visitNone();
public abstract T visitTableRef(TableRef tableRef);
public abstract T visitBindings(Bindings bindings);
public T visitBinding(Binding binding) {
return binding.accept(
this::visitSingleBinding,
this::visitChoiceBinding,
this::visitTableBinding);
}
public abstract T visitSingleBinding(SingleBinding singleBinding);
public abstract T visitChoiceBinding(ChoiceBinding choiceBinding);
public abstract T visitTableBinding(TableBinding tableBinding);
public abstract T visitFourPhaseTest(FourPhaseTest fourPhaseTest);
public abstract T visitPhase(Phase phase);
public abstract T visitVerifyPhase(VerifyPhase verifyPhase);
public abstract T visitLetStatement(LetStatement letStatement);
public T visitStatement(Statement statement) {
return statement.accept(
this::visitExecution,
this::visitInvoke);
}
public abstract T visitExecution(Execution execution);
public abstract T visitInvoke(Invoke invoke);
public abstract T visitTable(Table table);
public abstract T visitRow(Row row);
public T visitCell(Cell cell) {
return cell.accept(
this::visitExprCell,
this::visitPredCell);
}
public abstract T visitExprCell(ExprCell exprCell);
public abstract T visitPredCell(PredCell predCell);
public abstract T visitCodeBlock(CodeBlock codeBlock);
public abstract T visitHeading(Heading heading);
public abstract T visitIdent(Ident ident);
}
| tkob/yokohamaunit | src/main/java/yokohama/unit/ast/AstVisitor.java | Java | mit | 6,022 | [
30522,
7427,
20507,
1012,
3131,
1012,
2004,
2102,
1025,
2270,
10061,
2465,
2004,
9189,
17417,
4263,
1026,
1056,
1028,
1063,
2270,
10061,
1056,
3942,
17058,
1006,
2177,
2177,
1007,
1025,
2270,
10061,
1056,
3942,
7875,
13578,
9035,
3508,
1006... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
# stable-node-version [](https://travis-ci.org/vadimdemedes/stable-node-version)
Fetch stable Node.js version.
### Installation
```
$ npm install stable-node-version --save
```
### Usage
```js
const fetchStableVersion = require('stable-node-version');
fetchStableVersion().then(stableVersion => {
stableVersion === '4.0.0'; // true
});
```
### Tests
[](https://travis-ci.org/vadimdemedes/stable-node-version)
```
$ make test
```
### License
MIT © [vdemedes](https://github.com/vdemedes)
| vdemedes/stable-node-version | Readme.md | Markdown | mit | 683 | [
30522,
1001,
6540,
1011,
13045,
1011,
2544,
1031,
999,
1031,
3857,
3570,
1033,
1006,
16770,
1024,
1013,
1013,
10001,
1011,
25022,
1012,
8917,
1013,
12436,
22172,
3207,
7583,
2229,
1013,
6540,
1011,
13045,
1011,
2544,
1012,
17917,
2290,
1029... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN">
<title>Balancing Overflow</title>
<style type="text/css">
.colset {
display: table;
border-collapse: separate;
border-spacing: 2px;
width: 204px;
}
p { background: orange; display: table-cell; height: 17px}
</style>
<div class="colset">
<p></p>
<p></p>
<p></p>
</div>
| tmhorne/celtx | layout/reftests/columns/column-balancing-overflow-004.ref.html | HTML | mpl-2.0 | 343 | [
30522,
1026,
999,
9986,
13874,
16129,
2270,
1000,
1011,
1013,
1013,
1059,
2509,
2278,
1013,
1013,
26718,
2094,
16129,
1018,
1012,
5890,
1013,
1013,
4372,
1000,
1028,
1026,
2516,
1028,
20120,
2058,
12314,
1026,
1013,
2516,
1028,
1026,
2806,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
/*
* linux/fs/ext4/xattr.c
*
* Copyright (C) 2001-2003 Andreas Gruenbacher, <agruen@suse.de>
*
* Fix by Harrison Xing <harrison@mountainviewdata.com>.
* Ext4 code with a lot of help from Eric Jarman <ejarman@acm.org>.
* Extended attributes for symlinks and special files added per
* suggestion of Luka Renko <luka.renko@hermes.si>.
* xattr consolidation Copyright (c) 2004 James Morris <jmorris@redhat.com>,
* Red Hat Inc.
* ea-in-inode support by Alex Tomas <alex@clusterfs.com> aka bzzz
* and Andreas Gruenbacher <agruen@suse.de>.
*/
/*
* Extended attributes are stored directly in inodes (on file systems with
* inodes bigger than 128 bytes) and on additional disk blocks. The i_file_acl
* field contains the block number if an inode uses an additional block. All
* attributes must fit in the inode and one additional block. Blocks that
* contain the identical set of attributes may be shared among several inodes.
* Identical blocks are detected by keeping a cache of blocks that have
* recently been accessed.
*
* The attributes in inodes and on blocks have a different header; the entries
* are stored in the same format:
*
* +------------------+
* | header |
* | entry 1 | |
* | entry 2 | | growing downwards
* | entry 3 | v
* | four null bytes |
* | . . . |
* | value 1 | ^
* | value 3 | | growing upwards
* | value 2 | |
* +------------------+
*
* The header is followed by multiple entry descriptors. In disk blocks, the
* entry descriptors are kept sorted. In inodes, they are unsorted. The
* attribute values are aligned to the end of the block in no specific order.
*
* Locking strategy
* ----------------
* EXT4_I(inode)->i_file_acl is protected by EXT4_I(inode)->xattr_sem.
* EA blocks are only changed if they are exclusive to an inode, so
* holding xattr_sem also means that nothing but the EA block's reference
* count can change. Multiple writers to the same block are synchronized
* by the buffer lock.
*/
#include <linux/init.h>
#include <linux/fs.h>
#include <linux/slab.h>
#include <linux/mbcache.h>
#include <linux/quotaops.h>
#include <linux/rwsem.h>
#include "ext4_jbd2.h"
#include "ext4.h"
#include "xattr.h"
#include "acl.h"
#define BHDR(bh) ((struct ext4_xattr_header *)((bh)->b_data))
#define ENTRY(ptr) ((struct ext4_xattr_entry *)(ptr))
#define BFIRST(bh) ENTRY(BHDR(bh)+1)
#define IS_LAST_ENTRY(entry) (*(__u32 *)(entry) == 0)
#ifdef EXT4_XATTR_DEBUG
# define ea_idebug(inode, f...) do { \
printk(KERN_DEBUG "inode %s:%lu: ", \
inode->i_sb->s_id, inode->i_ino); \
printk(f); \
printk("\n"); \
} while (0)
# define ea_bdebug(bh, f...) do { \
char b[BDEVNAME_SIZE]; \
printk(KERN_DEBUG "block %s:%lu: ", \
bdevname(bh->b_bdev, b), \
(unsigned long) bh->b_blocknr); \
printk(f); \
printk("\n"); \
} while (0)
#else
# define ea_idebug(inode, fmt, ...) no_printk(fmt, ##__VA_ARGS__)
# define ea_bdebug(bh, fmt, ...) no_printk(fmt, ##__VA_ARGS__)
#endif
static void ext4_xattr_cache_insert(struct buffer_head *);
static struct buffer_head *ext4_xattr_cache_find(struct inode *,
struct ext4_xattr_header *,
struct mb_cache_entry **);
static void ext4_xattr_rehash(struct ext4_xattr_header *,
struct ext4_xattr_entry *);
static int ext4_xattr_list(struct dentry *dentry, char *buffer,
size_t buffer_size);
static struct mb_cache *ext4_xattr_cache;
static const struct xattr_handler *ext4_xattr_handler_map[] = {
[EXT4_XATTR_INDEX_USER] = &ext4_xattr_user_handler,
#ifdef CONFIG_EXT4_FS_POSIX_ACL
[EXT4_XATTR_INDEX_POSIX_ACL_ACCESS] = &ext4_xattr_acl_access_handler,
[EXT4_XATTR_INDEX_POSIX_ACL_DEFAULT] = &ext4_xattr_acl_default_handler,
#endif
[EXT4_XATTR_INDEX_TRUSTED] = &ext4_xattr_trusted_handler,
#ifdef CONFIG_EXT4_FS_SECURITY
[EXT4_XATTR_INDEX_SECURITY] = &ext4_xattr_security_handler,
#endif
};
const struct xattr_handler *ext4_xattr_handlers[] = {
&ext4_xattr_user_handler,
&ext4_xattr_trusted_handler,
#ifdef CONFIG_EXT4_FS_POSIX_ACL
&ext4_xattr_acl_access_handler,
&ext4_xattr_acl_default_handler,
#endif
#ifdef CONFIG_EXT4_FS_SECURITY
&ext4_xattr_security_handler,
#endif
NULL
};
static inline const struct xattr_handler *
ext4_xattr_handler(int name_index)
{
const struct xattr_handler *handler = NULL;
if (name_index > 0 && name_index < ARRAY_SIZE(ext4_xattr_handler_map))
handler = ext4_xattr_handler_map[name_index];
return handler;
}
/*
* Inode operation listxattr()
*
* dentry->d_inode->i_mutex: don't care
*/
ssize_t
ext4_listxattr(struct dentry *dentry, char *buffer, size_t size)
{
return ext4_xattr_list(dentry, buffer, size);
}
static int
ext4_xattr_check_names(struct ext4_xattr_entry *entry, void *end)
{
while (!IS_LAST_ENTRY(entry)) {
struct ext4_xattr_entry *next = EXT4_XATTR_NEXT(entry);
if ((void *)next >= end)
return -EIO;
entry = next;
}
return 0;
}
static inline int
ext4_xattr_check_block(struct buffer_head *bh)
{
if (BHDR(bh)->h_magic != cpu_to_le32(EXT4_XATTR_MAGIC) ||
BHDR(bh)->h_blocks != cpu_to_le32(1))
return -EIO;
return ext4_xattr_check_names(BFIRST(bh), bh->b_data + bh->b_size);
}
static inline int
ext4_xattr_check_entry(struct ext4_xattr_entry *entry, size_t size)
{
size_t value_size = le32_to_cpu(entry->e_value_size);
if (entry->e_value_block != 0 || value_size > size ||
le16_to_cpu(entry->e_value_offs) + value_size > size)
return -EIO;
return 0;
}
static int
ext4_xattr_find_entry(struct ext4_xattr_entry **pentry, int name_index,
const char *name, size_t size, int sorted)
{
struct ext4_xattr_entry *entry;
size_t name_len;
int cmp = 1;
if (name == NULL)
return -EINVAL;
name_len = strlen(name);
entry = *pentry;
for (; !IS_LAST_ENTRY(entry); entry = EXT4_XATTR_NEXT(entry)) {
cmp = name_index - entry->e_name_index;
if (!cmp)
cmp = name_len - entry->e_name_len;
if (!cmp)
cmp = memcmp(name, entry->e_name, name_len);
if (cmp <= 0 && (sorted || cmp == 0))
break;
}
*pentry = entry;
if (!cmp && ext4_xattr_check_entry(entry, size))
return -EIO;
return cmp ? -ENODATA : 0;
}
static int
ext4_xattr_block_get(struct inode *inode, int name_index, const char *name,
void *buffer, size_t buffer_size)
{
struct buffer_head *bh = NULL;
struct ext4_xattr_entry *entry;
size_t size;
int error;
ea_idebug(inode, "name=%d.%s, buffer=%p, buffer_size=%ld",
name_index, name, buffer, (long)buffer_size);
error = -ENODATA;
if (!EXT4_I(inode)->i_file_acl)
goto cleanup;
ea_idebug(inode, "reading block %llu",
(unsigned long long)EXT4_I(inode)->i_file_acl);
bh = sb_bread(inode->i_sb, EXT4_I(inode)->i_file_acl);
if (!bh)
goto cleanup;
ea_bdebug(bh, "b_count=%d, refcount=%d",
atomic_read(&(bh->b_count)), le32_to_cpu(BHDR(bh)->h_refcount));
if (ext4_xattr_check_block(bh)) {
bad_block:
EXT4_ERROR_INODE(inode, "bad block %llu",
EXT4_I(inode)->i_file_acl);
error = -EIO;
goto cleanup;
}
ext4_xattr_cache_insert(bh);
entry = BFIRST(bh);
error = ext4_xattr_find_entry(&entry, name_index, name, bh->b_size, 1);
if (error == -EIO)
goto bad_block;
if (error)
goto cleanup;
size = le32_to_cpu(entry->e_value_size);
if (buffer) {
error = -ERANGE;
if (size > buffer_size)
goto cleanup;
memcpy(buffer, bh->b_data + le16_to_cpu(entry->e_value_offs),
size);
}
error = size;
cleanup:
brelse(bh);
return error;
}
static int
ext4_xattr_ibody_get(struct inode *inode, int name_index, const char *name,
void *buffer, size_t buffer_size)
{
struct ext4_xattr_ibody_header *header;
struct ext4_xattr_entry *entry;
struct ext4_inode *raw_inode;
struct ext4_iloc iloc;
size_t size;
void *end;
int error;
if (!ext4_test_inode_state(inode, EXT4_STATE_XATTR))
return -ENODATA;
error = ext4_get_inode_loc(inode, &iloc);
if (error)
return error;
raw_inode = ext4_raw_inode(&iloc);
header = IHDR(inode, raw_inode);
entry = IFIRST(header);
end = (void *)raw_inode + EXT4_SB(inode->i_sb)->s_inode_size;
error = ext4_xattr_check_names(entry, end);
if (error)
goto cleanup;
error = ext4_xattr_find_entry(&entry, name_index, name,
end - (void *)entry, 0);
if (error)
goto cleanup;
size = le32_to_cpu(entry->e_value_size);
if (buffer) {
error = -ERANGE;
if (size > buffer_size)
goto cleanup;
memcpy(buffer, (void *)IFIRST(header) +
le16_to_cpu(entry->e_value_offs), size);
}
error = size;
cleanup:
brelse(iloc.bh);
return error;
}
/*
* ext4_xattr_get()
*
* Copy an extended attribute into the buffer
* provided, or compute the buffer size required.
* Buffer is NULL to compute the size of the buffer required.
*
* Returns a negative error number on failure, or the number of bytes
* used / required on success.
*/
int
ext4_xattr_get(struct inode *inode, int name_index, const char *name,
void *buffer, size_t buffer_size)
{
int error;
down_read(&EXT4_I(inode)->xattr_sem);
error = ext4_xattr_ibody_get(inode, name_index, name, buffer,
buffer_size);
if (error == -ENODATA)
error = ext4_xattr_block_get(inode, name_index, name, buffer,
buffer_size);
up_read(&EXT4_I(inode)->xattr_sem);
return error;
}
static int
ext4_xattr_list_entries(struct dentry *dentry, struct ext4_xattr_entry *entry,
char *buffer, size_t buffer_size)
{
size_t rest = buffer_size;
for (; !IS_LAST_ENTRY(entry); entry = EXT4_XATTR_NEXT(entry)) {
const struct xattr_handler *handler =
ext4_xattr_handler(entry->e_name_index);
if (handler) {
size_t size = handler->list(dentry, buffer, rest,
entry->e_name,
entry->e_name_len,
handler->flags);
if (buffer) {
if (size > rest)
return -ERANGE;
buffer += size;
}
rest -= size;
}
}
return buffer_size - rest;
}
static int
ext4_xattr_block_list(struct dentry *dentry, char *buffer, size_t buffer_size)
{
struct inode *inode = dentry->d_inode;
struct buffer_head *bh = NULL;
int error;
ea_idebug(inode, "buffer=%p, buffer_size=%ld",
buffer, (long)buffer_size);
error = 0;
if (!EXT4_I(inode)->i_file_acl)
goto cleanup;
ea_idebug(inode, "reading block %llu",
(unsigned long long)EXT4_I(inode)->i_file_acl);
bh = sb_bread(inode->i_sb, EXT4_I(inode)->i_file_acl);
error = -EIO;
if (!bh)
goto cleanup;
ea_bdebug(bh, "b_count=%d, refcount=%d",
atomic_read(&(bh->b_count)), le32_to_cpu(BHDR(bh)->h_refcount));
if (ext4_xattr_check_block(bh)) {
EXT4_ERROR_INODE(inode, "bad block %llu",
EXT4_I(inode)->i_file_acl);
error = -EIO;
goto cleanup;
}
ext4_xattr_cache_insert(bh);
error = ext4_xattr_list_entries(dentry, BFIRST(bh), buffer, buffer_size);
cleanup:
brelse(bh);
return error;
}
static int
ext4_xattr_ibody_list(struct dentry *dentry, char *buffer, size_t buffer_size)
{
struct inode *inode = dentry->d_inode;
struct ext4_xattr_ibody_header *header;
struct ext4_inode *raw_inode;
struct ext4_iloc iloc;
void *end;
int error;
if (!ext4_test_inode_state(inode, EXT4_STATE_XATTR))
return 0;
error = ext4_get_inode_loc(inode, &iloc);
if (error)
return error;
raw_inode = ext4_raw_inode(&iloc);
header = IHDR(inode, raw_inode);
end = (void *)raw_inode + EXT4_SB(inode->i_sb)->s_inode_size;
error = ext4_xattr_check_names(IFIRST(header), end);
if (error)
goto cleanup;
error = ext4_xattr_list_entries(dentry, IFIRST(header),
buffer, buffer_size);
cleanup:
brelse(iloc.bh);
return error;
}
/*
* ext4_xattr_list()
*
* Copy a list of attribute names into the buffer
* provided, or compute the buffer size required.
* Buffer is NULL to compute the size of the buffer required.
*
* Returns a negative error number on failure, or the number of bytes
* used / required on success.
*/
static int
ext4_xattr_list(struct dentry *dentry, char *buffer, size_t buffer_size)
{
int ret, ret2;
down_read(&EXT4_I(dentry->d_inode)->xattr_sem);
ret = ret2 = ext4_xattr_ibody_list(dentry, buffer, buffer_size);
if (ret < 0)
goto errout;
if (buffer) {
buffer += ret;
buffer_size -= ret;
}
ret = ext4_xattr_block_list(dentry, buffer, buffer_size);
if (ret < 0)
goto errout;
ret += ret2;
errout:
up_read(&EXT4_I(dentry->d_inode)->xattr_sem);
return ret;
}
/*
* If the EXT4_FEATURE_COMPAT_EXT_ATTR feature of this file system is
* not set, set it.
*/
static void ext4_xattr_update_super_block(handle_t *handle,
struct super_block *sb)
{
if (EXT4_HAS_COMPAT_FEATURE(sb, EXT4_FEATURE_COMPAT_EXT_ATTR))
return;
if (ext4_journal_get_write_access(handle, EXT4_SB(sb)->s_sbh) == 0) {
EXT4_SET_COMPAT_FEATURE(sb, EXT4_FEATURE_COMPAT_EXT_ATTR);
ext4_handle_dirty_super(handle, sb);
}
}
/*
* Release the xattr block BH: If the reference count is > 1, decrement
* it; otherwise free the block.
*/
static void
ext4_xattr_release_block(handle_t *handle, struct inode *inode,
struct buffer_head *bh)
{
struct mb_cache_entry *ce = NULL;
int error = 0;
ce = mb_cache_entry_get(ext4_xattr_cache, bh->b_bdev, bh->b_blocknr);
error = ext4_journal_get_write_access(handle, bh);
if (error)
goto out;
lock_buffer(bh);
if (BHDR(bh)->h_refcount == cpu_to_le32(1)) {
ea_bdebug(bh, "refcount now=0; freeing");
if (ce)
mb_cache_entry_free(ce);
get_bh(bh);
ext4_free_blocks(handle, inode, bh, 0, 1,
EXT4_FREE_BLOCKS_METADATA |
EXT4_FREE_BLOCKS_FORGET);
unlock_buffer(bh);
} else {
le32_add_cpu(&BHDR(bh)->h_refcount, -1);
if (ce)
mb_cache_entry_release(ce);
unlock_buffer(bh);
error = ext4_handle_dirty_metadata(handle, inode, bh);
if (IS_SYNC(inode))
ext4_handle_sync(handle);
dquot_free_block(inode, EXT4_C2B(EXT4_SB(inode->i_sb), 1));
ea_bdebug(bh, "refcount now=%d; releasing",
le32_to_cpu(BHDR(bh)->h_refcount));
}
out:
ext4_std_error(inode->i_sb, error);
return;
}
/*
* Find the available free space for EAs. This also returns the total number of
* bytes used by EA entries.
*/
static size_t ext4_xattr_free_space(struct ext4_xattr_entry *last,
size_t *min_offs, void *base, int *total)
{
for (; !IS_LAST_ENTRY(last); last = EXT4_XATTR_NEXT(last)) {
*total += EXT4_XATTR_LEN(last->e_name_len);
if (!last->e_value_block && last->e_value_size) {
size_t offs = le16_to_cpu(last->e_value_offs);
if (offs < *min_offs)
*min_offs = offs;
}
}
return (*min_offs - ((void *)last - base) - sizeof(__u32));
}
struct ext4_xattr_info {
int name_index;
const char *name;
const void *value;
size_t value_len;
};
struct ext4_xattr_search {
struct ext4_xattr_entry *first;
void *base;
void *end;
struct ext4_xattr_entry *here;
int not_found;
};
static int
ext4_xattr_set_entry(struct ext4_xattr_info *i, struct ext4_xattr_search *s)
{
struct ext4_xattr_entry *last;
size_t free, min_offs = s->end - s->base, name_len = strlen(i->name);
/* Compute min_offs and last. */
last = s->first;
for (; !IS_LAST_ENTRY(last); last = EXT4_XATTR_NEXT(last)) {
if (!last->e_value_block && last->e_value_size) {
size_t offs = le16_to_cpu(last->e_value_offs);
if (offs < min_offs)
min_offs = offs;
}
}
free = min_offs - ((void *)last - s->base) - sizeof(__u32);
if (!s->not_found) {
if (!s->here->e_value_block && s->here->e_value_size) {
size_t size = le32_to_cpu(s->here->e_value_size);
free += EXT4_XATTR_SIZE(size);
}
free += EXT4_XATTR_LEN(name_len);
}
if (i->value) {
if (free < EXT4_XATTR_SIZE(i->value_len) ||
free < EXT4_XATTR_LEN(name_len) +
EXT4_XATTR_SIZE(i->value_len))
return -ENOSPC;
}
if (i->value && s->not_found) {
/* Insert the new name. */
size_t size = EXT4_XATTR_LEN(name_len);
size_t rest = (void *)last - (void *)s->here + sizeof(__u32);
memmove((void *)s->here + size, s->here, rest);
memset(s->here, 0, size);
s->here->e_name_index = i->name_index;
s->here->e_name_len = name_len;
memcpy(s->here->e_name, i->name, name_len);
} else {
if (!s->here->e_value_block && s->here->e_value_size) {
void *first_val = s->base + min_offs;
size_t offs = le16_to_cpu(s->here->e_value_offs);
void *val = s->base + offs;
size_t size = EXT4_XATTR_SIZE(
le32_to_cpu(s->here->e_value_size));
if (i->value && size == EXT4_XATTR_SIZE(i->value_len)) {
/* The old and the new value have the same
size. Just replace. */
s->here->e_value_size =
cpu_to_le32(i->value_len);
memset(val + size - EXT4_XATTR_PAD, 0,
EXT4_XATTR_PAD); /* Clear pad bytes. */
memcpy(val, i->value, i->value_len);
return 0;
}
/* Remove the old value. */
memmove(first_val + size, first_val, val - first_val);
memset(first_val, 0, size);
s->here->e_value_size = 0;
s->here->e_value_offs = 0;
min_offs += size;
/* Adjust all value offsets. */
last = s->first;
while (!IS_LAST_ENTRY(last)) {
size_t o = le16_to_cpu(last->e_value_offs);
if (!last->e_value_block &&
last->e_value_size && o < offs)
last->e_value_offs =
cpu_to_le16(o + size);
last = EXT4_XATTR_NEXT(last);
}
}
if (!i->value) {
/* Remove the old name. */
size_t size = EXT4_XATTR_LEN(name_len);
last = ENTRY((void *)last - size);
memmove(s->here, (void *)s->here + size,
(void *)last - (void *)s->here + sizeof(__u32));
memset(last, 0, size);
}
}
if (i->value) {
/* Insert the new value. */
s->here->e_value_size = cpu_to_le32(i->value_len);
if (i->value_len) {
size_t size = EXT4_XATTR_SIZE(i->value_len);
void *val = s->base + min_offs - size;
s->here->e_value_offs = cpu_to_le16(min_offs - size);
memset(val + size - EXT4_XATTR_PAD, 0,
EXT4_XATTR_PAD); /* Clear the pad bytes. */
memcpy(val, i->value, i->value_len);
}
}
return 0;
}
struct ext4_xattr_block_find {
struct ext4_xattr_search s;
struct buffer_head *bh;
};
static int
ext4_xattr_block_find(struct inode *inode, struct ext4_xattr_info *i,
struct ext4_xattr_block_find *bs)
{
struct super_block *sb = inode->i_sb;
int error;
ea_idebug(inode, "name=%d.%s, value=%p, value_len=%ld",
i->name_index, i->name, i->value, (long)i->value_len);
if (EXT4_I(inode)->i_file_acl) {
/* The inode already has an extended attribute block. */
bs->bh = sb_bread(sb, EXT4_I(inode)->i_file_acl);
error = -EIO;
if (!bs->bh)
goto cleanup;
ea_bdebug(bs->bh, "b_count=%d, refcount=%d",
atomic_read(&(bs->bh->b_count)),
le32_to_cpu(BHDR(bs->bh)->h_refcount));
if (ext4_xattr_check_block(bs->bh)) {
EXT4_ERROR_INODE(inode, "bad block %llu",
EXT4_I(inode)->i_file_acl);
error = -EIO;
goto cleanup;
}
/* Find the named attribute. */
bs->s.base = BHDR(bs->bh);
bs->s.first = BFIRST(bs->bh);
bs->s.end = bs->bh->b_data + bs->bh->b_size;
bs->s.here = bs->s.first;
error = ext4_xattr_find_entry(&bs->s.here, i->name_index,
i->name, bs->bh->b_size, 1);
if (error && error != -ENODATA)
goto cleanup;
bs->s.not_found = error;
}
error = 0;
cleanup:
return error;
}
static int
ext4_xattr_block_set(handle_t *handle, struct inode *inode,
struct ext4_xattr_info *i,
struct ext4_xattr_block_find *bs)
{
struct super_block *sb = inode->i_sb;
struct buffer_head *new_bh = NULL;
struct ext4_xattr_search *s = &bs->s;
struct mb_cache_entry *ce = NULL;
int error = 0;
#define header(x) ((struct ext4_xattr_header *)(x))
if (i->value && i->value_len > sb->s_blocksize)
return -ENOSPC;
if (s->base) {
ce = mb_cache_entry_get(ext4_xattr_cache, bs->bh->b_bdev,
bs->bh->b_blocknr);
error = ext4_journal_get_write_access(handle, bs->bh);
if (error)
goto cleanup;
lock_buffer(bs->bh);
if (header(s->base)->h_refcount == cpu_to_le32(1)) {
if (ce) {
mb_cache_entry_free(ce);
ce = NULL;
}
ea_bdebug(bs->bh, "modifying in-place");
error = ext4_xattr_set_entry(i, s);
if (!error) {
if (!IS_LAST_ENTRY(s->first))
ext4_xattr_rehash(header(s->base),
s->here);
ext4_xattr_cache_insert(bs->bh);
}
unlock_buffer(bs->bh);
if (error == -EIO)
goto bad_block;
if (!error)
error = ext4_handle_dirty_metadata(handle,
inode,
bs->bh);
if (error)
goto cleanup;
goto inserted;
} else {
int offset = (char *)s->here - bs->bh->b_data;
unlock_buffer(bs->bh);
ext4_handle_release_buffer(handle, bs->bh);
if (ce) {
mb_cache_entry_release(ce);
ce = NULL;
}
ea_bdebug(bs->bh, "cloning");
s->base = kmalloc(bs->bh->b_size, GFP_NOFS);
error = -ENOMEM;
if (s->base == NULL)
goto cleanup;
memcpy(s->base, BHDR(bs->bh), bs->bh->b_size);
s->first = ENTRY(header(s->base)+1);
header(s->base)->h_refcount = cpu_to_le32(1);
s->here = ENTRY(s->base + offset);
s->end = s->base + bs->bh->b_size;
}
} else {
/* Allocate a buffer where we construct the new block. */
s->base = kzalloc(sb->s_blocksize, GFP_NOFS);
/* assert(header == s->base) */
error = -ENOMEM;
if (s->base == NULL)
goto cleanup;
header(s->base)->h_magic = cpu_to_le32(EXT4_XATTR_MAGIC);
header(s->base)->h_blocks = cpu_to_le32(1);
header(s->base)->h_refcount = cpu_to_le32(1);
s->first = ENTRY(header(s->base)+1);
s->here = ENTRY(header(s->base)+1);
s->end = s->base + sb->s_blocksize;
}
error = ext4_xattr_set_entry(i, s);
if (error == -EIO)
goto bad_block;
if (error)
goto cleanup;
if (!IS_LAST_ENTRY(s->first))
ext4_xattr_rehash(header(s->base), s->here);
inserted:
if (!IS_LAST_ENTRY(s->first)) {
new_bh = ext4_xattr_cache_find(inode, header(s->base), &ce);
if (new_bh) {
/* We found an identical block in the cache. */
if (new_bh == bs->bh)
ea_bdebug(new_bh, "keeping");
else {
/* The old block is released after updating
the inode. */
error = dquot_alloc_block(inode,
EXT4_C2B(EXT4_SB(sb), 1));
if (error)
goto cleanup;
error = ext4_journal_get_write_access(handle,
new_bh);
if (error)
goto cleanup_dquot;
lock_buffer(new_bh);
le32_add_cpu(&BHDR(new_bh)->h_refcount, 1);
ea_bdebug(new_bh, "reusing; refcount now=%d",
le32_to_cpu(BHDR(new_bh)->h_refcount));
unlock_buffer(new_bh);
error = ext4_handle_dirty_metadata(handle,
inode,
new_bh);
if (error)
goto cleanup_dquot;
}
mb_cache_entry_release(ce);
ce = NULL;
} else if (bs->bh && s->base == bs->bh->b_data) {
/* We were modifying this block in-place. */
ea_bdebug(bs->bh, "keeping this block");
new_bh = bs->bh;
get_bh(new_bh);
} else {
/* We need to allocate a new block */
ext4_fsblk_t goal, block;
goal = ext4_group_first_block_no(sb,
EXT4_I(inode)->i_block_group);
/* non-extent files can't have physical blocks past 2^32 */
if (!(ext4_test_inode_flag(inode, EXT4_INODE_EXTENTS)))
goal = goal & EXT4_MAX_BLOCK_FILE_PHYS;
/*
* take i_data_sem because we will test
* i_delalloc_reserved_flag in ext4_mb_new_blocks
*/
down_read((&EXT4_I(inode)->i_data_sem));
block = ext4_new_meta_blocks(handle, inode, goal, 0,
NULL, &error);
up_read((&EXT4_I(inode)->i_data_sem));
if (error)
goto cleanup;
if (!(ext4_test_inode_flag(inode, EXT4_INODE_EXTENTS)))
BUG_ON(block > EXT4_MAX_BLOCK_FILE_PHYS);
ea_idebug(inode, "creating block %llu",
(unsigned long long)block);
new_bh = sb_getblk(sb, block);
if (!new_bh) {
error = -ENOMEM;
getblk_failed:
ext4_free_blocks(handle, inode, NULL, block, 1,
EXT4_FREE_BLOCKS_METADATA);
goto cleanup;
}
lock_buffer(new_bh);
error = ext4_journal_get_create_access(handle, new_bh);
if (error) {
unlock_buffer(new_bh);
error = -EIO;
goto getblk_failed;
}
memcpy(new_bh->b_data, s->base, new_bh->b_size);
set_buffer_uptodate(new_bh);
unlock_buffer(new_bh);
ext4_xattr_cache_insert(new_bh);
error = ext4_handle_dirty_metadata(handle,
inode, new_bh);
if (error)
goto cleanup;
}
}
/* Update the inode. */
EXT4_I(inode)->i_file_acl = new_bh ? new_bh->b_blocknr : 0;
/* Drop the previous xattr block. */
if (bs->bh && bs->bh != new_bh)
ext4_xattr_release_block(handle, inode, bs->bh);
error = 0;
cleanup:
if (ce)
mb_cache_entry_release(ce);
brelse(new_bh);
if (!(bs->bh && s->base == bs->bh->b_data))
kfree(s->base);
return error;
cleanup_dquot:
dquot_free_block(inode, EXT4_C2B(EXT4_SB(sb), 1));
goto cleanup;
bad_block:
EXT4_ERROR_INODE(inode, "bad block %llu",
EXT4_I(inode)->i_file_acl);
goto cleanup;
#undef header
}
struct ext4_xattr_ibody_find {
struct ext4_xattr_search s;
struct ext4_iloc iloc;
};
static int
ext4_xattr_ibody_find(struct inode *inode, struct ext4_xattr_info *i,
struct ext4_xattr_ibody_find *is)
{
struct ext4_xattr_ibody_header *header;
struct ext4_inode *raw_inode;
int error;
if (EXT4_I(inode)->i_extra_isize == 0)
return 0;
raw_inode = ext4_raw_inode(&is->iloc);
header = IHDR(inode, raw_inode);
is->s.base = is->s.first = IFIRST(header);
is->s.here = is->s.first;
is->s.end = (void *)raw_inode + EXT4_SB(inode->i_sb)->s_inode_size;
if (ext4_test_inode_state(inode, EXT4_STATE_XATTR)) {
error = ext4_xattr_check_names(IFIRST(header), is->s.end);
if (error)
return error;
/* Find the named attribute. */
error = ext4_xattr_find_entry(&is->s.here, i->name_index,
i->name, is->s.end -
(void *)is->s.base, 0);
if (error && error != -ENODATA)
return error;
is->s.not_found = error;
}
return 0;
}
static int
ext4_xattr_ibody_set(handle_t *handle, struct inode *inode,
struct ext4_xattr_info *i,
struct ext4_xattr_ibody_find *is)
{
struct ext4_xattr_ibody_header *header;
struct ext4_xattr_search *s = &is->s;
int error;
if (EXT4_I(inode)->i_extra_isize == 0)
return -ENOSPC;
error = ext4_xattr_set_entry(i, s);
if (error)
return error;
header = IHDR(inode, ext4_raw_inode(&is->iloc));
if (!IS_LAST_ENTRY(s->first)) {
header->h_magic = cpu_to_le32(EXT4_XATTR_MAGIC);
ext4_set_inode_state(inode, EXT4_STATE_XATTR);
} else {
header->h_magic = cpu_to_le32(0);
ext4_clear_inode_state(inode, EXT4_STATE_XATTR);
}
return 0;
}
/*
* ext4_xattr_set_handle()
*
* Create, replace or remove an extended attribute for this inode. Value
* is NULL to remove an existing extended attribute, and non-NULL to
* either replace an existing extended attribute, or create a new extended
* attribute. The flags XATTR_REPLACE and XATTR_CREATE
* specify that an extended attribute must exist and must not exist
* previous to the call, respectively.
*
* Returns 0, or a negative error number on failure.
*/
int
ext4_xattr_set_handle(handle_t *handle, struct inode *inode, int name_index,
const char *name, const void *value, size_t value_len,
int flags)
{
struct ext4_xattr_info i = {
.name_index = name_index,
.name = name,
.value = value,
.value_len = value_len,
};
struct ext4_xattr_ibody_find is = {
.s = { .not_found = -ENODATA, },
};
struct ext4_xattr_block_find bs = {
.s = { .not_found = -ENODATA, },
};
unsigned long no_expand;
int error;
if (!name)
return -EINVAL;
if (strlen(name) > 255)
return -ERANGE;
down_write(&EXT4_I(inode)->xattr_sem);
no_expand = ext4_test_inode_state(inode, EXT4_STATE_NO_EXPAND);
ext4_set_inode_state(inode, EXT4_STATE_NO_EXPAND);
error = ext4_reserve_inode_write(handle, inode, &is.iloc);
if (error)
goto cleanup;
if (ext4_test_inode_state(inode, EXT4_STATE_NEW)) {
struct ext4_inode *raw_inode = ext4_raw_inode(&is.iloc);
memset(raw_inode, 0, EXT4_SB(inode->i_sb)->s_inode_size);
ext4_clear_inode_state(inode, EXT4_STATE_NEW);
}
error = ext4_xattr_ibody_find(inode, &i, &is);
if (error)
goto cleanup;
if (is.s.not_found)
error = ext4_xattr_block_find(inode, &i, &bs);
if (error)
goto cleanup;
if (is.s.not_found && bs.s.not_found) {
error = -ENODATA;
if (flags & XATTR_REPLACE)
goto cleanup;
error = 0;
if (!value)
goto cleanup;
} else {
error = -EEXIST;
if (flags & XATTR_CREATE)
goto cleanup;
}
if (!value) {
if (!is.s.not_found)
error = ext4_xattr_ibody_set(handle, inode, &i, &is);
else if (!bs.s.not_found)
error = ext4_xattr_block_set(handle, inode, &i, &bs);
} else {
error = ext4_xattr_ibody_set(handle, inode, &i, &is);
if (!error && !bs.s.not_found) {
i.value = NULL;
error = ext4_xattr_block_set(handle, inode, &i, &bs);
} else if (error == -ENOSPC) {
if (EXT4_I(inode)->i_file_acl && !bs.s.base) {
error = ext4_xattr_block_find(inode, &i, &bs);
if (error)
goto cleanup;
}
error = ext4_xattr_block_set(handle, inode, &i, &bs);
if (error)
goto cleanup;
if (!is.s.not_found) {
i.value = NULL;
error = ext4_xattr_ibody_set(handle, inode, &i,
&is);
}
}
}
if (!error) {
ext4_xattr_update_super_block(handle, inode->i_sb);
inode->i_ctime = ext4_current_time(inode);
if (!value)
ext4_clear_inode_state(inode, EXT4_STATE_NO_EXPAND);
error = ext4_mark_iloc_dirty(handle, inode, &is.iloc);
/*
* The bh is consumed by ext4_mark_iloc_dirty, even with
* error != 0.
*/
is.iloc.bh = NULL;
if (IS_SYNC(inode))
ext4_handle_sync(handle);
}
cleanup:
brelse(is.iloc.bh);
brelse(bs.bh);
if (no_expand == 0)
ext4_clear_inode_state(inode, EXT4_STATE_NO_EXPAND);
up_write(&EXT4_I(inode)->xattr_sem);
return error;
}
/*
* ext4_xattr_set()
*
* Like ext4_xattr_set_handle, but start from an inode. This extended
* attribute modification is a filesystem transaction by itself.
*
* Returns 0, or a negative error number on failure.
*/
int
ext4_xattr_set(struct inode *inode, int name_index, const char *name,
const void *value, size_t value_len, int flags)
{
handle_t *handle;
int error, retries = 0;
retry:
handle = ext4_journal_start(inode, EXT4_DATA_TRANS_BLOCKS(inode->i_sb));
if (IS_ERR(handle)) {
error = PTR_ERR(handle);
} else {
int error2;
error = ext4_xattr_set_handle(handle, inode, name_index, name,
value, value_len, flags);
error2 = ext4_journal_stop(handle);
if (error == -ENOSPC &&
ext4_should_retry_alloc(inode->i_sb, &retries))
goto retry;
if (error == 0)
error = error2;
}
return error;
}
/*
* Shift the EA entries in the inode to create space for the increased
* i_extra_isize.
*/
static void ext4_xattr_shift_entries(struct ext4_xattr_entry *entry,
int value_offs_shift, void *to,
void *from, size_t n, int blocksize)
{
struct ext4_xattr_entry *last = entry;
int new_offs;
/* Adjust the value offsets of the entries */
for (; !IS_LAST_ENTRY(last); last = EXT4_XATTR_NEXT(last)) {
if (!last->e_value_block && last->e_value_size) {
new_offs = le16_to_cpu(last->e_value_offs) +
value_offs_shift;
BUG_ON(new_offs + le32_to_cpu(last->e_value_size)
> blocksize);
last->e_value_offs = cpu_to_le16(new_offs);
}
}
/* Shift the entries by n bytes */
memmove(to, from, n);
}
/*
* Expand an inode by new_extra_isize bytes when EAs are present.
* Returns 0 on success or negative error number on failure.
*/
int ext4_expand_extra_isize_ea(struct inode *inode, int new_extra_isize,
struct ext4_inode *raw_inode, handle_t *handle)
{
struct ext4_xattr_ibody_header *header;
struct ext4_xattr_entry *entry, *last, *first;
struct buffer_head *bh = NULL;
struct ext4_xattr_ibody_find *is = NULL;
struct ext4_xattr_block_find *bs = NULL;
char *buffer = NULL, *b_entry_name = NULL;
size_t min_offs, free;
int total_ino, total_blk;
void *base, *start, *end;
int extra_isize = 0, error = 0, tried_min_extra_isize = 0;
int s_min_extra_isize = le16_to_cpu(EXT4_SB(inode->i_sb)->s_es->s_min_extra_isize);
down_write(&EXT4_I(inode)->xattr_sem);
retry:
if (EXT4_I(inode)->i_extra_isize >= new_extra_isize) {
up_write(&EXT4_I(inode)->xattr_sem);
return 0;
}
header = IHDR(inode, raw_inode);
entry = IFIRST(header);
/*
* Check if enough free space is available in the inode to shift the
* entries ahead by new_extra_isize.
*/
base = start = entry;
end = (void *)raw_inode + EXT4_SB(inode->i_sb)->s_inode_size;
min_offs = end - base;
last = entry;
total_ino = sizeof(struct ext4_xattr_ibody_header);
free = ext4_xattr_free_space(last, &min_offs, base, &total_ino);
if (free >= new_extra_isize) {
entry = IFIRST(header);
ext4_xattr_shift_entries(entry, EXT4_I(inode)->i_extra_isize
- new_extra_isize, (void *)raw_inode +
EXT4_GOOD_OLD_INODE_SIZE + new_extra_isize,
(void *)header, total_ino,
inode->i_sb->s_blocksize);
EXT4_I(inode)->i_extra_isize = new_extra_isize;
error = 0;
goto cleanup;
}
/*
* Enough free space isn't available in the inode, check if
* EA block can hold new_extra_isize bytes.
*/
if (EXT4_I(inode)->i_file_acl) {
bh = sb_bread(inode->i_sb, EXT4_I(inode)->i_file_acl);
error = -EIO;
if (!bh)
goto cleanup;
if (ext4_xattr_check_block(bh)) {
EXT4_ERROR_INODE(inode, "bad block %llu",
EXT4_I(inode)->i_file_acl);
error = -EIO;
goto cleanup;
}
base = BHDR(bh);
first = BFIRST(bh);
end = bh->b_data + bh->b_size;
min_offs = end - base;
free = ext4_xattr_free_space(first, &min_offs, base,
&total_blk);
if (free < new_extra_isize) {
if (!tried_min_extra_isize && s_min_extra_isize) {
tried_min_extra_isize++;
new_extra_isize = s_min_extra_isize;
brelse(bh);
goto retry;
}
error = -1;
goto cleanup;
}
} else {
free = inode->i_sb->s_blocksize;
}
while (new_extra_isize > 0) {
size_t offs, size, entry_size;
struct ext4_xattr_entry *small_entry = NULL;
struct ext4_xattr_info i = {
.value = NULL,
.value_len = 0,
};
unsigned int total_size; /* EA entry size + value size */
unsigned int shift_bytes; /* No. of bytes to shift EAs by? */
unsigned int min_total_size = ~0U;
is = kzalloc(sizeof(struct ext4_xattr_ibody_find), GFP_NOFS);
bs = kzalloc(sizeof(struct ext4_xattr_block_find), GFP_NOFS);
if (!is || !bs) {
error = -ENOMEM;
goto cleanup;
}
is->s.not_found = -ENODATA;
bs->s.not_found = -ENODATA;
is->iloc.bh = NULL;
bs->bh = NULL;
last = IFIRST(header);
/* Find the entry best suited to be pushed into EA block */
entry = NULL;
for (; !IS_LAST_ENTRY(last); last = EXT4_XATTR_NEXT(last)) {
total_size =
EXT4_XATTR_SIZE(le32_to_cpu(last->e_value_size)) +
EXT4_XATTR_LEN(last->e_name_len);
if (total_size <= free && total_size < min_total_size) {
if (total_size < new_extra_isize) {
small_entry = last;
} else {
entry = last;
min_total_size = total_size;
}
}
}
if (entry == NULL) {
if (small_entry) {
entry = small_entry;
} else {
if (!tried_min_extra_isize &&
s_min_extra_isize) {
tried_min_extra_isize++;
new_extra_isize = s_min_extra_isize;
kfree(is); is = NULL;
kfree(bs); bs = NULL;
goto retry;
}
error = -1;
goto cleanup;
}
}
offs = le16_to_cpu(entry->e_value_offs);
size = le32_to_cpu(entry->e_value_size);
entry_size = EXT4_XATTR_LEN(entry->e_name_len);
i.name_index = entry->e_name_index,
buffer = kmalloc(EXT4_XATTR_SIZE(size), GFP_NOFS);
b_entry_name = kmalloc(entry->e_name_len + 1, GFP_NOFS);
if (!buffer || !b_entry_name) {
error = -ENOMEM;
goto cleanup;
}
/* Save the entry name and the entry value */
memcpy(buffer, (void *)IFIRST(header) + offs,
EXT4_XATTR_SIZE(size));
memcpy(b_entry_name, entry->e_name, entry->e_name_len);
b_entry_name[entry->e_name_len] = '\0';
i.name = b_entry_name;
error = ext4_get_inode_loc(inode, &is->iloc);
if (error)
goto cleanup;
error = ext4_xattr_ibody_find(inode, &i, is);
if (error)
goto cleanup;
/* Remove the chosen entry from the inode */
error = ext4_xattr_ibody_set(handle, inode, &i, is);
if (error)
goto cleanup;
entry = IFIRST(header);
if (entry_size + EXT4_XATTR_SIZE(size) >= new_extra_isize)
shift_bytes = new_extra_isize;
else
shift_bytes = entry_size + size;
/* Adjust the offsets and shift the remaining entries ahead */
ext4_xattr_shift_entries(entry, EXT4_I(inode)->i_extra_isize -
shift_bytes, (void *)raw_inode +
EXT4_GOOD_OLD_INODE_SIZE + extra_isize + shift_bytes,
(void *)header, total_ino - entry_size,
inode->i_sb->s_blocksize);
extra_isize += shift_bytes;
new_extra_isize -= shift_bytes;
EXT4_I(inode)->i_extra_isize = extra_isize;
i.name = b_entry_name;
i.value = buffer;
i.value_len = size;
error = ext4_xattr_block_find(inode, &i, bs);
if (error)
goto cleanup;
/* Add entry which was removed from the inode into the block */
error = ext4_xattr_block_set(handle, inode, &i, bs);
if (error)
goto cleanup;
kfree(b_entry_name);
kfree(buffer);
b_entry_name = NULL;
buffer = NULL;
brelse(is->iloc.bh);
kfree(is);
kfree(bs);
}
brelse(bh);
up_write(&EXT4_I(inode)->xattr_sem);
return 0;
cleanup:
kfree(b_entry_name);
kfree(buffer);
if (is)
brelse(is->iloc.bh);
kfree(is);
kfree(bs);
brelse(bh);
up_write(&EXT4_I(inode)->xattr_sem);
return error;
}
/*
* ext4_xattr_delete_inode()
*
* Free extended attribute resources associated with this inode. This
* is called immediately before an inode is freed. We have exclusive
* access to the inode.
*/
void
ext4_xattr_delete_inode(handle_t *handle, struct inode *inode)
{
struct buffer_head *bh = NULL;
if (!EXT4_I(inode)->i_file_acl)
goto cleanup;
bh = sb_bread(inode->i_sb, EXT4_I(inode)->i_file_acl);
if (!bh) {
EXT4_ERROR_INODE(inode, "block %llu read error",
EXT4_I(inode)->i_file_acl);
goto cleanup;
}
if (BHDR(bh)->h_magic != cpu_to_le32(EXT4_XATTR_MAGIC) ||
BHDR(bh)->h_blocks != cpu_to_le32(1)) {
EXT4_ERROR_INODE(inode, "bad block %llu",
EXT4_I(inode)->i_file_acl);
goto cleanup;
}
ext4_xattr_release_block(handle, inode, bh);
EXT4_I(inode)->i_file_acl = 0;
cleanup:
brelse(bh);
}
/*
* ext4_xattr_put_super()
*
* This is called when a file system is unmounted.
*/
void
ext4_xattr_put_super(struct super_block *sb)
{
mb_cache_shrink(sb->s_bdev);
}
/*
* ext4_xattr_cache_insert()
*
* Create a new entry in the extended attribute cache, and insert
* it unless such an entry is already in the cache.
*
* Returns 0, or a negative error number on failure.
*/
static void
ext4_xattr_cache_insert(struct buffer_head *bh)
{
__u32 hash = le32_to_cpu(BHDR(bh)->h_hash);
struct mb_cache_entry *ce;
int error;
ce = mb_cache_entry_alloc(ext4_xattr_cache, GFP_NOFS);
if (!ce) {
ea_bdebug(bh, "out of memory");
return;
}
error = mb_cache_entry_insert(ce, bh->b_bdev, bh->b_blocknr, hash);
if (error) {
mb_cache_entry_free(ce);
if (error == -EBUSY) {
ea_bdebug(bh, "already in cache");
error = 0;
}
} else {
ea_bdebug(bh, "inserting [%x]", (int)hash);
mb_cache_entry_release(ce);
}
}
/*
* ext4_xattr_cmp()
*
* Compare two extended attribute blocks for equality.
*
* Returns 0 if the blocks are equal, 1 if they differ, and
* a negative error number on errors.
*/
static int
ext4_xattr_cmp(struct ext4_xattr_header *header1,
struct ext4_xattr_header *header2)
{
struct ext4_xattr_entry *entry1, *entry2;
entry1 = ENTRY(header1+1);
entry2 = ENTRY(header2+1);
while (!IS_LAST_ENTRY(entry1)) {
if (IS_LAST_ENTRY(entry2))
return 1;
if (entry1->e_hash != entry2->e_hash ||
entry1->e_name_index != entry2->e_name_index ||
entry1->e_name_len != entry2->e_name_len ||
entry1->e_value_size != entry2->e_value_size ||
memcmp(entry1->e_name, entry2->e_name, entry1->e_name_len))
return 1;
if (entry1->e_value_block != 0 || entry2->e_value_block != 0)
return -EIO;
if (memcmp((char *)header1 + le16_to_cpu(entry1->e_value_offs),
(char *)header2 + le16_to_cpu(entry2->e_value_offs),
le32_to_cpu(entry1->e_value_size)))
return 1;
entry1 = EXT4_XATTR_NEXT(entry1);
entry2 = EXT4_XATTR_NEXT(entry2);
}
if (!IS_LAST_ENTRY(entry2))
return 1;
return 0;
}
/*
* ext4_xattr_cache_find()
*
* Find an identical extended attribute block.
*
* Returns a pointer to the block found, or NULL if such a block was
* not found or an error occurred.
*/
static struct buffer_head *
ext4_xattr_cache_find(struct inode *inode, struct ext4_xattr_header *header,
struct mb_cache_entry **pce)
{
__u32 hash = le32_to_cpu(header->h_hash);
struct mb_cache_entry *ce;
if (!header->h_hash)
return NULL; /* never share */
ea_idebug(inode, "looking for cached blocks [%x]", (int)hash);
again:
ce = mb_cache_entry_find_first(ext4_xattr_cache, inode->i_sb->s_bdev,
hash);
while (ce) {
struct buffer_head *bh;
if (IS_ERR(ce)) {
if (PTR_ERR(ce) == -EAGAIN)
goto again;
break;
}
bh = sb_bread(inode->i_sb, ce->e_block);
if (!bh) {
EXT4_ERROR_INODE(inode, "block %lu read error",
(unsigned long) ce->e_block);
} else if (le32_to_cpu(BHDR(bh)->h_refcount) >=
EXT4_XATTR_REFCOUNT_MAX) {
ea_idebug(inode, "block %lu refcount %d>=%d",
(unsigned long) ce->e_block,
le32_to_cpu(BHDR(bh)->h_refcount),
EXT4_XATTR_REFCOUNT_MAX);
} else if (ext4_xattr_cmp(header, BHDR(bh)) == 0) {
*pce = ce;
return bh;
}
brelse(bh);
ce = mb_cache_entry_find_next(ce, inode->i_sb->s_bdev, hash);
}
return NULL;
}
#define NAME_HASH_SHIFT 5
#define VALUE_HASH_SHIFT 16
/*
* ext4_xattr_hash_entry()
*
* Compute the hash of an extended attribute.
*/
static inline void ext4_xattr_hash_entry(struct ext4_xattr_header *header,
struct ext4_xattr_entry *entry)
{
__u32 hash = 0;
char *name = entry->e_name;
int n;
for (n = 0; n < entry->e_name_len; n++) {
hash = (hash << NAME_HASH_SHIFT) ^
(hash >> (8*sizeof(hash) - NAME_HASH_SHIFT)) ^
*name++;
}
if (entry->e_value_block == 0 && entry->e_value_size != 0) {
__le32 *value = (__le32 *)((char *)header +
le16_to_cpu(entry->e_value_offs));
for (n = (le32_to_cpu(entry->e_value_size) +
EXT4_XATTR_ROUND) >> EXT4_XATTR_PAD_BITS; n; n--) {
hash = (hash << VALUE_HASH_SHIFT) ^
(hash >> (8*sizeof(hash) - VALUE_HASH_SHIFT)) ^
le32_to_cpu(*value++);
}
}
entry->e_hash = cpu_to_le32(hash);
}
#undef NAME_HASH_SHIFT
#undef VALUE_HASH_SHIFT
#define BLOCK_HASH_SHIFT 16
/*
* ext4_xattr_rehash()
*
* Re-compute the extended attribute hash value after an entry has changed.
*/
static void ext4_xattr_rehash(struct ext4_xattr_header *header,
struct ext4_xattr_entry *entry)
{
struct ext4_xattr_entry *here;
__u32 hash = 0;
ext4_xattr_hash_entry(header, entry);
here = ENTRY(header+1);
while (!IS_LAST_ENTRY(here)) {
if (!here->e_hash) {
/* Block is not shared if an entry's hash value == 0 */
hash = 0;
break;
}
hash = (hash << BLOCK_HASH_SHIFT) ^
(hash >> (8*sizeof(hash) - BLOCK_HASH_SHIFT)) ^
le32_to_cpu(here->e_hash);
here = EXT4_XATTR_NEXT(here);
}
header->h_hash = cpu_to_le32(hash);
}
#undef BLOCK_HASH_SHIFT
int __init
ext4_init_xattr(void)
{
ext4_xattr_cache = mb_cache_create("ext4_xattr", 6);
if (!ext4_xattr_cache)
return -ENOMEM;
return 0;
}
void
ext4_exit_xattr(void)
{
if (ext4_xattr_cache)
mb_cache_destroy(ext4_xattr_cache);
ext4_xattr_cache = NULL;
}
| davidmueller13/AK-Flo | fs/ext4/xattr.c | C | gpl-2.0 | 43,253 | [
30522,
1013,
1008,
1008,
11603,
1013,
1042,
2015,
1013,
4654,
2102,
2549,
1013,
1060,
19321,
2099,
1012,
1039,
1008,
1008,
9385,
1006,
1039,
1007,
2541,
1011,
2494,
12460,
24665,
24997,
7693,
2121,
1010,
1026,
12943,
6820,
2368,
1030,
10514... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<!-- NewPage -->
<html lang="en">
<head>
<!-- Generated by javadoc (1.8.0_112) on Fri Jun 16 09:55:07 MST 2017 -->
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>InMemoryAuthenticationConsumer (Public javadocs 2017.6.1 API)</title>
<meta name="date" content="2017-06-16">
<link rel="stylesheet" type="text/css" href="../../../../stylesheet.css" title="Style">
<script type="text/javascript" src="../../../../script.js"></script>
</head>
<body>
<script type="text/javascript"><!--
try {
if (location.href.indexOf('is-external=true') == -1) {
parent.document.title="InMemoryAuthenticationConsumer (Public javadocs 2017.6.1 API)";
}
}
catch(err) {
}
//-->
var methods = {"i0":6};
var tabs = {65535:["t0","All Methods"],2:["t2","Instance Methods"],4:["t3","Abstract Methods"]};
var altColor = "altColor";
var rowColor = "rowColor";
var tableTab = "tableTab";
var activeTableTab = "activeTableTab";
</script>
<noscript>
<div>JavaScript is disabled on your browser.</div>
</noscript>
<!-- ========= START OF TOP NAVBAR ======= -->
<div class="topNav"><a name="navbar.top">
<!-- -->
</a>
<div class="skipNav"><a href="#skip.navbar.top" title="Skip navigation links">Skip navigation links</a></div>
<a name="navbar.top.firstrow">
<!-- -->
</a>
<ul class="navList" title="Navigation">
<li><a href="../../../../overview-summary.html">Overview</a></li>
<li><a href="package-summary.html">Package</a></li>
<li class="navBarCell1Rev">Class</li>
<li><a href="class-use/InMemoryAuthenticationConsumer.html">Use</a></li>
<li><a href="package-tree.html">Tree</a></li>
<li><a href="../../../../deprecated-list.html">Deprecated</a></li>
<li><a href="../../../../index-all.html">Index</a></li>
<li><a href="../../../../help-doc.html">Help</a></li>
</ul>
<div class="aboutLanguage">WildFly Swarm API, 2017.6.1</div>
</div>
<div class="subNav">
<ul class="navList">
<li><a href="../../../../org/wildfly/swarm/management/InMemoryAuthentication.html" title="class in org.wildfly.swarm.management"><span class="typeNameLink">Prev Class</span></a></li>
<li><a href="../../../../org/wildfly/swarm/management/InMemoryAuthorization.html" title="class in org.wildfly.swarm.management"><span class="typeNameLink">Next Class</span></a></li>
</ul>
<ul class="navList">
<li><a href="../../../../index.html?org/wildfly/swarm/management/InMemoryAuthenticationConsumer.html" target="_top">Frames</a></li>
<li><a href="InMemoryAuthenticationConsumer.html" target="_top">No Frames</a></li>
</ul>
<ul class="navList" id="allclasses_navbar_top">
<li><a href="../../../../allclasses-noframe.html">All Classes</a></li>
</ul>
<div>
<script type="text/javascript"><!--
allClassesLink = document.getElementById("allclasses_navbar_top");
if(window==top) {
allClassesLink.style.display = "block";
}
else {
allClassesLink.style.display = "none";
}
//-->
</script>
</div>
<div>
<ul class="subNavList">
<li>Summary: </li>
<li>Nested | </li>
<li>Field | </li>
<li>Constr | </li>
<li><a href="#method.summary">Method</a></li>
</ul>
<ul class="subNavList">
<li>Detail: </li>
<li>Field | </li>
<li>Constr | </li>
<li><a href="#method.detail">Method</a></li>
</ul>
</div>
<a name="skip.navbar.top">
<!-- -->
</a></div>
<!-- ========= END OF TOP NAVBAR ========= -->
<!-- ======== START OF CLASS DATA ======== -->
<div class="header">
<div class="subTitle">org.wildfly.swarm.management</div>
<h2 title="Interface InMemoryAuthenticationConsumer" class="title">Interface InMemoryAuthenticationConsumer</h2>
</div>
<div class="contentContainer">
<div class="description">
<ul class="blockList">
<li class="blockList">
<dl>
<dt>Functional Interface:</dt>
<dd>This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.</dd>
</dl>
<hr>
<br>
<pre><a href="http://docs.oracle.com/javase/8/docs/api/java/lang/FunctionalInterface.html?is-external=true" title="class or interface in java.lang">@FunctionalInterface</a>
public interface <span class="typeNameLabel">InMemoryAuthenticationConsumer</span></pre>
<dl>
<dt><span class="simpleTagLabel">Author:</span></dt>
<dd>Bob McWhirter</dd>
</dl>
</li>
</ul>
</div>
<div class="summary">
<ul class="blockList">
<li class="blockList">
<!-- ========== METHOD SUMMARY =========== -->
<ul class="blockList">
<li class="blockList"><a name="method.summary">
<!-- -->
</a>
<h3>Method Summary</h3>
<table class="memberSummary" border="0" cellpadding="3" cellspacing="0" summary="Method Summary table, listing methods, and an explanation">
<caption><span id="t0" class="activeTableTab"><span>All Methods</span><span class="tabEnd"> </span></span><span id="t2" class="tableTab"><span><a href="javascript:show(2);">Instance Methods</a></span><span class="tabEnd"> </span></span><span id="t3" class="tableTab"><span><a href="javascript:show(4);">Abstract Methods</a></span><span class="tabEnd"> </span></span></caption>
<tr>
<th class="colFirst" scope="col">Modifier and Type</th>
<th class="colLast" scope="col">Method and Description</th>
</tr>
<tr id="i0" class="altColor">
<td class="colFirst"><code>void</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../org/wildfly/swarm/management/InMemoryAuthenticationConsumer.html#accept-org.wildfly.swarm.management.InMemoryAuthentication-">accept</a></span>(<a href="../../../../org/wildfly/swarm/management/InMemoryAuthentication.html" title="class in org.wildfly.swarm.management">InMemoryAuthentication</a> authn)</code> </td>
</tr>
</table>
</li>
</ul>
</li>
</ul>
</div>
<div class="details">
<ul class="blockList">
<li class="blockList">
<!-- ============ METHOD DETAIL ========== -->
<ul class="blockList">
<li class="blockList"><a name="method.detail">
<!-- -->
</a>
<h3>Method Detail</h3>
<a name="accept-org.wildfly.swarm.management.InMemoryAuthentication-">
<!-- -->
</a>
<ul class="blockListLast">
<li class="blockList">
<h4>accept</h4>
<pre>void accept(<a href="../../../../org/wildfly/swarm/management/InMemoryAuthentication.html" title="class in org.wildfly.swarm.management">InMemoryAuthentication</a> authn)</pre>
</li>
</ul>
</li>
</ul>
</li>
</ul>
</div>
</div>
<!-- ========= END OF CLASS DATA ========= -->
<!-- ======= START OF BOTTOM NAVBAR ====== -->
<div class="bottomNav"><a name="navbar.bottom">
<!-- -->
</a>
<div class="skipNav"><a href="#skip.navbar.bottom" title="Skip navigation links">Skip navigation links</a></div>
<a name="navbar.bottom.firstrow">
<!-- -->
</a>
<ul class="navList" title="Navigation">
<li><a href="../../../../overview-summary.html">Overview</a></li>
<li><a href="package-summary.html">Package</a></li>
<li class="navBarCell1Rev">Class</li>
<li><a href="class-use/InMemoryAuthenticationConsumer.html">Use</a></li>
<li><a href="package-tree.html">Tree</a></li>
<li><a href="../../../../deprecated-list.html">Deprecated</a></li>
<li><a href="../../../../index-all.html">Index</a></li>
<li><a href="../../../../help-doc.html">Help</a></li>
</ul>
<div class="aboutLanguage">WildFly Swarm API, 2017.6.1</div>
</div>
<div class="subNav">
<ul class="navList">
<li><a href="../../../../org/wildfly/swarm/management/InMemoryAuthentication.html" title="class in org.wildfly.swarm.management"><span class="typeNameLink">Prev Class</span></a></li>
<li><a href="../../../../org/wildfly/swarm/management/InMemoryAuthorization.html" title="class in org.wildfly.swarm.management"><span class="typeNameLink">Next Class</span></a></li>
</ul>
<ul class="navList">
<li><a href="../../../../index.html?org/wildfly/swarm/management/InMemoryAuthenticationConsumer.html" target="_top">Frames</a></li>
<li><a href="InMemoryAuthenticationConsumer.html" target="_top">No Frames</a></li>
</ul>
<ul class="navList" id="allclasses_navbar_bottom">
<li><a href="../../../../allclasses-noframe.html">All Classes</a></li>
</ul>
<div>
<script type="text/javascript"><!--
allClassesLink = document.getElementById("allclasses_navbar_bottom");
if(window==top) {
allClassesLink.style.display = "block";
}
else {
allClassesLink.style.display = "none";
}
//-->
</script>
</div>
<div>
<ul class="subNavList">
<li>Summary: </li>
<li>Nested | </li>
<li>Field | </li>
<li>Constr | </li>
<li><a href="#method.summary">Method</a></li>
</ul>
<ul class="subNavList">
<li>Detail: </li>
<li>Field | </li>
<li>Constr | </li>
<li><a href="#method.detail">Method</a></li>
</ul>
</div>
<a name="skip.navbar.bottom">
<!-- -->
</a></div>
<!-- ======== END OF BOTTOM NAVBAR ======= -->
<p class="legalCopy"><small>Copyright © 2017 <a href="http://www.jboss.org">JBoss by Red Hat</a>. All rights reserved.</small></p>
</body>
</html>
| wildfly-swarm/wildfly-swarm-javadocs | 2017.6.1/apidocs/org/wildfly/swarm/management/InMemoryAuthenticationConsumer.html | HTML | apache-2.0 | 8,980 | [
30522,
1026,
999,
9986,
13874,
16129,
2270,
1000,
1011,
1013,
1013,
1059,
2509,
2278,
1013,
1013,
26718,
2094,
16129,
1018,
1012,
5890,
17459,
1013,
1013,
4372,
1000,
1000,
8299,
1024,
1013,
1013,
7479,
1012,
1059,
2509,
1012,
8917,
1013,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
// Copyright (c) 2019 Cisco and/or its affiliates.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at:
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package vpp2001
import (
"bytes"
"net"
"github.com/ligato/vpp-agent/plugins/vpp/l2plugin/vppcalls"
"github.com/pkg/errors"
l2 "github.com/ligato/vpp-agent/api/models/vpp/l2"
vpp_l2 "github.com/ligato/vpp-agent/plugins/vpp/binapi/vpp2001/l2"
)
// DumpBridgeDomains implements bridge domain handler.
func (h *BridgeDomainVppHandler) DumpBridgeDomains() ([]*vppcalls.BridgeDomainDetails, error) {
// At first prepare bridge domain ARP termination table which needs to be dumped separately.
bdArpTab, err := h.dumpBridgeDomainMacTable()
if err != nil {
return nil, errors.Errorf("failed to dump arp termination table: %v", err)
}
// list of resulting BDs
var bds []*vppcalls.BridgeDomainDetails
// dump bridge domains
reqCtx := h.callsChannel.SendMultiRequest(&vpp_l2.BridgeDomainDump{BdID: ^uint32(0)})
for {
bdDetails := &vpp_l2.BridgeDomainDetails{}
stop, err := reqCtx.ReceiveReply(bdDetails)
if stop {
break
}
if err != nil {
return nil, err
}
// bridge domain metadata
bdData := &vppcalls.BridgeDomainDetails{
Bd: &l2.BridgeDomain{
Name: string(bytes.Replace(bdDetails.BdTag, []byte{0x00}, []byte{}, -1)),
Flood: bdDetails.Flood > 0,
UnknownUnicastFlood: bdDetails.UuFlood > 0,
Forward: bdDetails.Forward > 0,
Learn: bdDetails.Learn > 0,
ArpTermination: bdDetails.ArpTerm > 0,
MacAge: uint32(bdDetails.MacAge),
},
Meta: &vppcalls.BridgeDomainMeta{
BdID: bdDetails.BdID,
},
}
// bridge domain interfaces
for _, iface := range bdDetails.SwIfDetails {
ifaceName, _, exists := h.ifIndexes.LookupBySwIfIndex(iface.SwIfIndex)
if !exists {
h.log.Warnf("Bridge domain dump: interface name for index %d not found", iface.SwIfIndex)
continue
}
// Bvi
var bvi bool
if iface.SwIfIndex == bdDetails.BviSwIfIndex {
bvi = true
}
// add interface entry
bdData.Bd.Interfaces = append(bdData.Bd.Interfaces, &l2.BridgeDomain_Interface{
Name: ifaceName,
BridgedVirtualInterface: bvi,
SplitHorizonGroup: uint32(iface.Shg),
})
}
// Add ARP termination entries.
arpTable, ok := bdArpTab[bdDetails.BdID]
if ok {
bdData.Bd.ArpTerminationTable = arpTable
}
bds = append(bds, bdData)
}
return bds, nil
}
// Reads ARP termination table from all bridge domains. Result is then added to bridge domains.
func (h *BridgeDomainVppHandler) dumpBridgeDomainMacTable() (map[uint32][]*l2.BridgeDomain_ArpTerminationEntry, error) {
bdArpTable := make(map[uint32][]*l2.BridgeDomain_ArpTerminationEntry)
req := &vpp_l2.BdIPMacDump{BdID: ^uint32(0)}
reqCtx := h.callsChannel.SendMultiRequest(req)
for {
msg := &vpp_l2.BdIPMacDetails{}
stop, err := reqCtx.ReceiveReply(msg)
if err != nil {
return nil, err
}
if stop {
break
}
// Prepare ARP entry
arpEntry := &l2.BridgeDomain_ArpTerminationEntry{}
arpEntry.IpAddress = parseAddressToString(msg.Entry.IP)
arpEntry.PhysAddress = net.HardwareAddr(msg.Entry.Mac[:]).String()
// Add ARP entry to result map
bdArpTable[msg.Entry.BdID] = append(bdArpTable[msg.Entry.BdID], arpEntry)
}
return bdArpTable, nil
}
// DumpL2FIBs dumps VPP L2 FIB table entries into the northbound API
// data structure map indexed by destination MAC address.
func (h *FIBVppHandler) DumpL2FIBs() (map[string]*vppcalls.FibTableDetails, error) {
// map for the resulting FIBs
fibs := make(map[string]*vppcalls.FibTableDetails)
reqCtx := h.callsChannel.SendMultiRequest(&vpp_l2.L2FibTableDump{BdID: ^uint32(0)})
for {
fibDetails := &vpp_l2.L2FibTableDetails{}
stop, err := reqCtx.ReceiveReply(fibDetails)
if stop {
break // Break from the loop.
}
if err != nil {
return nil, err
}
mac := net.HardwareAddr(fibDetails.Mac).String()
var action l2.FIBEntry_Action
if fibDetails.FilterMac > 0 {
action = l2.FIBEntry_DROP
} else {
action = l2.FIBEntry_FORWARD
}
// Interface name (only for FORWARD entries)
var ifName string
if action == l2.FIBEntry_FORWARD {
var exists bool
ifName, _, exists = h.ifIndexes.LookupBySwIfIndex(fibDetails.SwIfIndex)
if !exists {
h.log.Warnf("FIB dump: interface name for index %d not found", fibDetails.SwIfIndex)
continue
}
}
// Bridge domain name
bdName, _, exists := h.bdIndexes.LookupByIndex(fibDetails.BdID)
if !exists {
h.log.Warnf("FIB dump: bridge domain name for index %d not found", fibDetails.BdID)
continue
}
fibs[mac] = &vppcalls.FibTableDetails{
Fib: &l2.FIBEntry{
PhysAddress: mac,
BridgeDomain: bdName,
Action: action,
OutgoingInterface: ifName,
StaticConfig: fibDetails.StaticMac > 0,
BridgedVirtualInterface: fibDetails.BviMac > 0,
},
Meta: &vppcalls.FibMeta{
BdID: fibDetails.BdID,
IfIdx: fibDetails.SwIfIndex,
},
}
}
return fibs, nil
}
// DumpXConnectPairs implements xconnect handler.
func (h *XConnectVppHandler) DumpXConnectPairs() (map[uint32]*vppcalls.XConnectDetails, error) {
// map for the resulting xconnect pairs
xpairs := make(map[uint32]*vppcalls.XConnectDetails)
reqCtx := h.callsChannel.SendMultiRequest(&vpp_l2.L2XconnectDump{})
for {
pairs := &vpp_l2.L2XconnectDetails{}
stop, err := reqCtx.ReceiveReply(pairs)
if stop {
break
}
if err != nil {
return nil, err
}
// Find interface names
rxIfaceName, _, exists := h.ifIndexes.LookupBySwIfIndex(pairs.RxSwIfIndex)
if !exists {
h.log.Warnf("XConnect dump: rx interface name for index %d not found", pairs.RxSwIfIndex)
continue
}
txIfaceName, _, exists := h.ifIndexes.LookupBySwIfIndex(pairs.TxSwIfIndex)
if !exists {
h.log.Warnf("XConnect dump: tx interface name for index %d not found", pairs.TxSwIfIndex)
continue
}
xpairs[pairs.RxSwIfIndex] = &vppcalls.XConnectDetails{
Xc: &l2.XConnectPair{
ReceiveInterface: rxIfaceName,
TransmitInterface: txIfaceName,
},
Meta: &vppcalls.XcMeta{
ReceiveInterfaceSwIfIdx: pairs.RxSwIfIndex,
TransmitInterfaceSwIfIdx: pairs.TxSwIfIndex,
},
}
}
return xpairs, nil
}
func parseAddressToString(address vpp_l2.Address) string {
var nhIP net.IP = make([]byte, 16)
copy(nhIP[:], address.Un.XXX_UnionData[:])
if address.Af == vpp_l2.ADDRESS_IP4 {
return nhIP[:4].To4().String()
}
if address.Af == vpp_l2.ADDRESS_IP6 {
return nhIP.To16().String()
}
return ""
}
| rastislavszabo/vpp | vendor/github.com/ligato/vpp-agent/plugins/vpp/l2plugin/vppcalls/vpp2001/dump_vppcalls.go | GO | apache-2.0 | 7,105 | [
30522,
1013,
1013,
9385,
1006,
1039,
1007,
10476,
26408,
1998,
1013,
2030,
2049,
18460,
1012,
1013,
1013,
1013,
1013,
7000,
2104,
1996,
15895,
6105,
1010,
2544,
1016,
1012,
1014,
1006,
1996,
1000,
6105,
1000,
1007,
1025,
1013,
1013,
2017,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
<?php
if (is_user_logged_in()) {
header("Location: " . get_bloginfo('url'));
exit(NULL);
}
/*
Template Name: Recover Password
*/
$accountReg = get_page_by_title($OPTION['wps_pgNavi_regOption']);
$accountLog = get_page_by_title($OPTION['wps_pgNavi_logOption']);
get_header();
$EMAIL = load_what_is_needed('email'); //change.9.10
if ($_GET) {
if ( isset($_GET['action']) && isset($_GET['key']) ) {
//reset and enter new password
?>
<form name="resetpassform" id="resetpassform" action="<?php echo esc_url( site_url( 'wp-login.php?action=resetpass&key=' . urlencode( $_GET['key'] ) . '&login=' . urlencode( $_GET['login'] ), 'login_post' ) ); ?>" method="post">
<input type="hidden" id="user_login" value="<?php echo esc_attr( $_GET['login'] ); ?>" autocomplete="off" />
<p>
<label for="pass1"><?php _e('New password') ?><br />
<input type="password" name="pass1" id="pass1" class="input" size="20" value="" autocomplete="off" /></label>
</p>
<p>
<label for="pass2"><?php _e('Confirm new password') ?><br />
<input type="password" name="pass2" id="pass2" class="input" size="20" value="" autocomplete="off" /></label>
</p>
<div id="pass-strength-result" class="hide-if-no-js"><?php _e('Strength indicator'); ?></div>
<p class="description indicator-hint"><?php _e('Hint: The password should be at least seven characters long. To make it stronger, use upper and lower case letters, numbers and symbols like ! " ? $ % ^ & ).'); ?></p>
<br class="clear" />
<p class="submit"><input type="submit" name="wp-submit" id="wp-submit" class="button-primary" value="<?php esc_attr_e('Reset Password'); ?>" tabindex="100" /></p>
</form>
<?php
exit(NULL);
}
}
if ( is_sidebar_active('account_log_widget_area')){$the_div_class = 'alignleft signInAcc';}else {$the_div_class = '';}?>
<div class="<?php echo $the_div_class; ?>" id="loginFormWrap">
<h2><?php _e('Enter your email address','wpShop');?></h2>
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<div <?php post_class('page_post'); ?> id="post-<?php the_ID(); ?>">
<?php the_content('<p class="serif">'. __( 'Read the rest of this page »', 'wpShop' ) . '</p>');
wp_link_pages(array('before' => '<p><strong>' . __( 'Pages:', 'wpShop' ) . '</strong> ', 'after' => '</p>', 'next_or_number' => 'number')); ?>
</div><!-- page_post -->
<?php endwhile; endif;
if($_POST){
// we remove any whitespaces
$uname = trim($_POST[signInUname]);
$email = trim($_POST[signInEmail]);
$table = is_dbtable_there('feusers');
$qStr = "SELECT * FROM $table WHERE uname='$uname' AND email ='$email'";
$res = mysql_query($qStr);
$num = mysql_num_rows($res);
//following steps only if there is such a uname/email combination
if($num != 0){
$done = 0;
// create password
$pw = generateRandomString();
$pwdb = md5(trim($pw));
// db update
$qStr = "UPDATE $table SET pw='$pwdb' WHERE uname='$uname' AND email ='$email'";
$done = mysql_query($qStr);
// email
$search = array("[##header##]","[##pw##]","[##login_link##]");
//change.9.10
$replace = array($EMAIL->email_header(),$pw,get_option('siteurl').'/'.$accountLog->post_name.'');
$EMAIL->email_password_reset($email,$search,$replace);
//\change.9.10
}
// redirect
if($done){
$url = get_real_base_url().'?reset=1';
echo "<meta http-equiv='refresh' content='0; URL=$url'>";
}
else{
$url = get_real_base_url().'?reset=0';
echo "<meta http-equiv='refresh' content='0; URL=$url'>";
}
}
if($_GET['reset'] == '1'){
echo "<div class='success'>".__('Your password was reset and sent. Please check your email!','wpShop')."</div>";
}
if($_GET['reset'] == '0'){
echo "<div class='error'>".__('Your user name and/or email address could not be found in our records. Try again.','wpShop')."</div>";
}
?>
<form method="post" action="<?php echo get_bloginfo('url') . '/wp-login.php?action=lostpassword'; ?>">
<fieldset>
<label for="signInUname"><?php _e('Username or Email','wpShop');?></label>
<input type="text" name="user_login" id="signInUname" size="35" maxlength="40" value="" />
<span class="passhelp"> <?php _e('A reset password will be sent to this email address.','wpShop');?></span>
<input type="hidden" name="redirect_to" value="<?php echo get_real_base_url().'?reset=1';?>"/>
<input class="formbutton" type="submit" alt="Sign in" value="Reset" name="" title="Reset" />
</fieldset>
</form>
<!-- <form method="post" action="<?php echo get_real_base_url(); ?>">
<fieldset>
<label for="signInUname"><?php _e('Username','wpShop');?></label>
<input type="text" name="signInUname" id="signInUname" size="35" maxlength="40" value="" />
<label for="signInEmail"><?php _e('Email','wpShop');?></label>
<input type="text" name="signInEmail" id="signInEmail" size="35" maxlength="40" value="" />
<span class="passhelp"> <?php _e('A reset password will be sent to this email address.','wpShop');?></span>
<input class="formbutton" type="submit" alt="Sign in" value="Reset" name="" title="Reset" />
</fieldset>
</form>
-->
</div>
<?php get_footer(); ?> | BalajiRamachandran/autos2day | wp-content/themes/TheClothesShop/lost_password.php | PHP | gpl-2.0 | 5,473 | [
30522,
1026,
1029,
25718,
2065,
1006,
2003,
1035,
5310,
1035,
26618,
30524,
1007,
1007,
1025,
6164,
1006,
19701,
1007,
1025,
1065,
1013,
1008,
23561,
2171,
1024,
8980,
20786,
1008,
1013,
1002,
4070,
2890,
2290,
1027,
2131,
1035,
3931,
1035,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
CLANG_LEVEL := ../..
DIRS := AST Basic Driver Lex Parse Sema Serialization
include $(CLANG_LEVEL)/Makefile
install-local::
$(Echo) Installing Clang include files
$(Verb) $(MKDIR) $(DESTDIR)$(PROJ_includedir)
$(Verb) if test -d "$(PROJ_SRC_DIR)" ; then \
cd $(PROJ_SRC_DIR)/.. && \
for hdr in `find clang -type f \
'(' -name LICENSE.TXT \
-o -name '*.def' \
-o -name '*.h' \
-o -name '*.inc' \
')' -print \
| grep -v CVS | grep -v .svn | grep -v .dir` ; do \
instdir=$(DESTDIR)`dirname "$(PROJ_includedir)/$$hdr"` ; \
if test \! -d "$$instdir" ; then \
$(EchoCmd) Making install directory $$instdir ; \
$(MKDIR) $$instdir ;\
fi ; \
$(DataInstall) $$hdr $(DESTDIR)$(PROJ_includedir)/$$hdr ; \
done ; \
fi
ifneq ($(PROJ_SRC_ROOT),$(PROJ_OBJ_ROOT))
$(Verb) if test -d "$(PROJ_OBJ_ROOT)/tools/clang/include/clang" ; then \
cd $(PROJ_OBJ_ROOT)/tools/clang/include && \
for hdr in `find clang -type f \
'(' -name LICENSE.TXT \
-o -name '*.def' \
-o -name '*.h' \
-o -name '*.inc' \
')' -print \
| grep -v CVS | grep -v .tmp | grep -v .dir` ; do \
instdir=$(DESTDIR)`dirname "$(PROJ_includedir)/$$hdr"` ; \
if test \! -d "$$instdir" ; then \
$(EchoCmd) Making install directory $$instdir ; \
$(MKDIR) $$instdir ;\
fi ; \
$(DataInstall) $$hdr $(DESTDIR)$(PROJ_includedir)/$$hdr ; \
done ; \
fi
endif
| jeltz/rust-debian-package | src/llvm/tools/clang/include/clang/Makefile | Makefile | apache-2.0 | 1,488 | [
30522,
6338,
2290,
1035,
2504,
1024,
1027,
1012,
1012,
1013,
1012,
1012,
16101,
2015,
1024,
1027,
2004,
2102,
3937,
4062,
17244,
11968,
3366,
7367,
2863,
7642,
3989,
2421,
1002,
1006,
6338,
2290,
1035,
2504,
1007,
1013,
2191,
8873,
2571,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
using System;
using System.Collections.Generic;
using UIKit;
using Foundation;
using System.Reflection;
namespace FontList.Code {
/// <summary>
/// Combined DataSource and Delegate for our UITableView
/// </summary>
public class NavItemTableSource : UITableViewSource
{
protected List<NavItemGroup> navItems;
string cellIdentifier = "NavTableCellView";
UINavigationController navigationController;
public NavItemTableSource (UINavigationController navigationController, List<NavItemGroup> items)
{
navItems = items;
this.navigationController = navigationController;
}
/// <summary>
/// Called by the TableView to determine how many sections(groups) there are.
/// </summary>
public override nint NumberOfSections (UITableView tableView)
{
return navItems.Count;
}
/// <summary>
/// Called by the TableView to determine how many cells to create for that particular section.
/// </summary>
public override nint RowsInSection (UITableView tableview, nint section)
{
return navItems[(int)section].Items.Count;
}
/// <summary>
/// Called by the TableView to retrieve the header text for the particular section(group)
/// </summary>
public override string TitleForHeader (UITableView tableView, nint section)
{
return navItems[(int)section].Name;
}
/// <summary>
/// Called by the TableView to retrieve the footer text for the particular section(group)
/// </summary>
public override string TitleForFooter (UITableView tableView, nint section)
{
return navItems[(int)section].Footer;
}
/// <summary>
/// Called by the TableView to actually build each cell.
/// </summary>
public override UITableViewCell GetCell (UITableView tableView, NSIndexPath indexPath)
{
NavItem navItem = this.navItems[indexPath.Section].Items[indexPath.Row];
var cell = tableView.DequeueReusableCell (this.cellIdentifier);
if (cell == null) {
cell = new UITableViewCell (UITableViewCellStyle.Default, this.cellIdentifier);
cell.Tag = Environment.TickCount;
}
//---- set the cell properties
cell.TextLabel.Text = this.navItems[indexPath.Section].Items[indexPath.Row].Name;
cell.Accessory = UITableViewCellAccessory.DisclosureIndicator;
if (navItem.Font != null)
{
cell.TextLabel.Font = navItem.Font;
}
return cell;
}
/// <summary>
/// Is called when a row is selected
/// </summary>
public override void RowSelected (UITableView tableView, NSIndexPath indexPath)
{
//---- get a reference to the nav item
NavItem navItem = navItems[indexPath.Section].Items[indexPath.Row];
// if the nav item has a proper controller, push it on to the NavigationController
// NOTE: we could also raise an event here, to loosely couple this, but isn't neccessary,
// because we'll only ever use this this way
if (navItem.Controller != null) {
navigationController.PushViewController (navItem.Controller, true);
// show the nav bar (we don't show it on the home page)
navigationController.NavigationBarHidden = false;
} else {
if (navItem.ControllerType != null) {
ConstructorInfo ctor = null;
// if the nav item has constructor aguments
if (navItem.ControllerConstructorArgs.Length > 0) {
// look for the constructor
ctor = navItem.ControllerType.GetConstructor (navItem.ControllerConstructorTypes);
} else {
// search for the default constructor
ctor = navItem.ControllerType.GetConstructor (System.Type.EmptyTypes);
}
// if we found the constructor
if (ctor != null) {
UIViewController instance = null;
if (navItem.ControllerConstructorArgs.Length > 0) {
// instance the view controller
instance = ctor.Invoke (navItem.ControllerConstructorArgs) as UIViewController;
} else {
// instance the view controller
instance = ctor.Invoke (null) as UIViewController;
}
if (instance != null) {
// save the object
navItem.Controller = instance;
// push the view controller onto the stack
navigationController.PushViewController (navItem.Controller, true);
} else {
Console.WriteLine ("instance of view controller not created");
}
} else {
Console.WriteLine ("constructor not found");
}
}
}
}
}
}
| davidrynn/monotouch-samples | FontList/Code/NavItemTableSource.cs | C# | mit | 4,333 | [
30522,
2478,
2291,
1025,
2478,
2291,
1012,
6407,
1012,
12391,
1025,
2478,
21318,
23615,
1025,
2478,
3192,
1025,
2478,
2291,
1012,
9185,
1025,
3415,
15327,
15489,
9863,
1012,
3642,
1063,
1013,
1013,
1013,
1026,
12654,
1028,
1013,
1013,
1013,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
// Copyright 2009-2015 Josh Close and Contributors
// This file is a part of CsvHelper and is dual licensed under MS-PL and Apache 2.0.
// See LICENSE.txt for details or visit http://www.opensource.org/licenses/ms-pl.html for MS-PL and http://opensource.org/licenses/Apache-2.0 for Apache 2.0.
// http://csvhelper.com
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Globalization;
using System.IO;
using System.Text;
using System.Threading;
using CsvHelper.Configuration;
using CsvHelper.TypeConversion;
using Int32Converter = CsvHelper.TypeConversion.Int32Converter;
#if !PCL
using System.Dynamic;
#endif
#if WINRT_4_5
using Microsoft.VisualStudio.TestPlatform.UnitTestFramework;
#else
using Microsoft.VisualStudio.TestTools.UnitTesting;
#endif
namespace CsvHelper.Tests
{
[TestClass]
public class CsvWriterTests
{
[TestInitialize]
public void TestInitialize()
{
Thread.CurrentThread.CurrentCulture = new CultureInfo("en-US");
}
[TestMethod]
public void WriteFieldTest()
{
var stream = new MemoryStream();
var writer = new StreamWriter(stream) { AutoFlush = true };
var csv = new CsvWriter(writer);
var date = DateTime.Now.ToString();
var guid = Guid.NewGuid().ToString();
csv.WriteField("one");
csv.WriteField("one, two");
csv.WriteField("one \"two\" three");
csv.WriteField(" one ");
csv.WriteField(date);
csv.WriteField((short)1);
csv.WriteField(1);
csv.WriteField((long)1);
csv.WriteField((float)1);
csv.WriteField((double)1);
csv.WriteField(guid);
csv.NextRecord();
var reader = new StreamReader(stream);
stream.Position = 0;
var data = reader.ReadToEnd();
Assert.AreEqual("one,\"one, two\",\"one \"\"two\"\" three\",\" one \"," + date + ",1,1,1,1,1," + guid + "\r\n", data);
}
[TestMethod]
public void WriteEmptyFieldWithExcelLeadingZerosTest()
{
using( var stream = new MemoryStream() )
using( var writer = new StreamWriter( stream ) )
using( var reader = new StreamReader( stream ) )
using( var csv = new CsvWriter( writer ) )
{
csv.Configuration.UseExcelLeadingZerosFormatForNumerics = true;
csv.WriteField( string.Empty );
}
}
[TestMethod]
public void WriteRecordTest()
{
var record = new TestRecord
{
IntColumn = 1,
StringColumn = "string column",
IgnoredColumn = "ignored column",
FirstColumn = "first column",
};
var stream = new MemoryStream();
var writer = new StreamWriter(stream) { AutoFlush = true };
var csv = new CsvWriter(writer);
csv.Configuration.RegisterClassMap<TestRecordMap>();
csv.WriteRecord(record);
stream.Position = 0;
var reader = new StreamReader(stream);
var csvFile = reader.ReadToEnd();
var expected = "first column,1,string column,test\r\n";
Assert.AreEqual(expected, csvFile);
}
[TestMethod]
public void WriteRecordNoIndexesTest()
{
var record = new TestRecordNoIndexes
{
IntColumn = 1,
StringColumn = "string column",
IgnoredColumn = "ignored column",
FirstColumn = "first column",
};
using (var stream = new MemoryStream())
using (var writer = new StreamWriter(stream) { AutoFlush = true })
using (var csv = new CsvWriter(writer))
{
csv.Configuration.RegisterClassMap<TestRecordNoIndexesMap>();
csv.WriteRecord(record);
stream.Position = 0;
var reader = new StreamReader(stream);
var csvFile = reader.ReadToEnd();
var expected = "1,string column,first column,test\r\n";
Assert.AreEqual(expected, csvFile);
}
}
[TestMethod]
public void WriteRecordsTest()
{
var records = new List<TestRecord>
{
new TestRecord
{
IntColumn = 1,
StringColumn = "string column",
IgnoredColumn = "ignored column",
FirstColumn = "first column",
},
new TestRecord
{
IntColumn = 2,
StringColumn = "string column 2",
IgnoredColumn = "ignored column 2",
FirstColumn = "first column 2",
},
};
var stream = new MemoryStream();
var writer = new StreamWriter(stream) { AutoFlush = true };
var csv = new CsvWriter(writer);
csv.Configuration.RegisterClassMap<TestRecordMap>();
csv.WriteRecords(records);
stream.Position = 0;
var reader = new StreamReader(stream);
var csvFile = reader.ReadToEnd();
var expected = "FirstColumn,Int Column,StringColumn,TypeConvertedColumn\r\n";
expected += "first column,1,string column,test\r\n";
expected += "first column 2,2,string column 2,test\r\n";
Assert.AreEqual(expected, csvFile);
}
[TestMethod]
public void WriteEmptyArrayTest()
{
var records = new TestRecord[] { };
var stream = new MemoryStream();
var writer = new StreamWriter(stream) { AutoFlush = true };
var csv = new CsvWriter(writer);
csv.Configuration.RegisterClassMap<TestRecordMap>();
csv.WriteRecords(records);
stream.Position = 0;
var reader = new StreamReader(stream);
var csvFile = reader.ReadToEnd();
var expected = "FirstColumn,Int Column,StringColumn,TypeConvertedColumn\r\n";
Assert.AreEqual(expected, csvFile);
}
[TestMethod]
public void WriteRecordsCalledWithTwoParametersTest()
{
var records = new List<object>
{
new TestRecord
{
IntColumn = 1,
StringColumn = "string column",
IgnoredColumn = "ignored column",
FirstColumn = "first column",
},
new TestRecord
{
IntColumn = 2,
StringColumn = "string column 2",
IgnoredColumn = "ignored column 2",
FirstColumn = "first column 2",
},
};
var stream = new MemoryStream();
var writer = new StreamWriter(stream) { AutoFlush = true };
var csv = new CsvWriter(writer);
csv.Configuration.RegisterClassMap<TestRecordMap>();
csv.WriteRecords(records);
stream.Position = 0;
var reader = new StreamReader(stream);
var csvFile = reader.ReadToEnd();
var expected = "FirstColumn,Int Column,StringColumn,TypeConvertedColumn\r\n";
expected += "first column,1,string column,test\r\n";
expected += "first column 2,2,string column 2,test\r\n";
Assert.AreEqual(expected, csvFile);
}
[TestMethod]
public void WriteRecordNoHeaderTest()
{
var stream = new MemoryStream();
var writer = new StreamWriter(stream) { AutoFlush = true };
var csv = new CsvWriter(writer) { Configuration = { HasHeaderRecord = false } };
csv.Configuration.RegisterClassMap<TestRecordMap>();
csv.WriteRecord(new TestRecord());
stream.Position = 0;
var reader = new StreamReader(stream);
var csvFile = reader.ReadToEnd();
Assert.AreEqual(",0,,test\r\n", csvFile);
}
[TestMethod]
public void WriteRecordWithNullRecordTest()
{
var record = new TestRecord
{
IntColumn = 1,
StringColumn = "string column",
IgnoredColumn = "ignored column",
FirstColumn = "first column",
};
var stream = new MemoryStream();
var writer = new StreamWriter(stream) { AutoFlush = true };
var csv = new CsvWriter(writer);
csv.Configuration.RegisterClassMap<TestRecordMap>();
csv.WriteRecord(record);
csv.WriteRecord((TestRecord)null);
csv.WriteRecord(record);
stream.Position = 0;
var reader = new StreamReader(stream);
var csvFile = reader.ReadToEnd();
var expected = "first column,1,string column,test\r\n";
expected += ",,,\r\n";
expected += "first column,1,string column,test\r\n";
Assert.AreEqual(expected, csvFile);
}
[TestMethod]
public void WriteRecordWithReferencesTest()
{
var record = new Person
{
FirstName = "First Name",
LastName = "Last Name",
HomeAddress = new Address
{
Street = "Home Street",
City = "Home City",
State = "Home State",
Zip = "Home Zip",
},
WorkAddress = new Address
{
Street = "Work Street",
City = "Work City",
State = "Work State",
Zip = "Work Zip",
}
};
var stream = new MemoryStream();
var writer = new StreamWriter(stream) { AutoFlush = true };
var csv = new CsvWriter(writer);
csv.Configuration.RegisterClassMap<PersonMap>();
csv.WriteRecord(record);
stream.Position = 0;
var reader = new StreamReader(stream);
var csvFile = reader.ReadToEnd();
var expected = "First Name,Last Name,Home Street,Home City,Home State,Home Zip,Work Street,Work City,Work State,Work Zip\r\n";
Assert.AreEqual(expected, csvFile);
}
[TestMethod]
public void WriteRecordsAllFieldsQuotedTest()
{
var record = new TestRecord
{
IntColumn = 1,
StringColumn = "string column",
IgnoredColumn = "ignored column",
FirstColumn = "first column",
};
string csv;
using (var stream = new MemoryStream())
using (var reader = new StreamReader(stream))
using (var writer = new StreamWriter(stream))
using (var csvWriter = new CsvWriter(writer))
{
csvWriter.Configuration.QuoteAllFields = true;
csvWriter.Configuration.RegisterClassMap<TestRecordMap>();
csvWriter.WriteRecord(record);
writer.Flush();
stream.Position = 0;
csv = reader.ReadToEnd();
}
var expected = "\"first column\",\"1\",\"string column\",\"test\"\r\n";
Assert.AreEqual(expected, csv);
}
[TestMethod]
public void WriteRecordsNoFieldsQuotedTest()
{
var record = new TestRecord
{
IntColumn = 1,
StringColumn = "string \" column",
IgnoredColumn = "ignored column",
FirstColumn = "first, column",
};
string csv;
using (var stream = new MemoryStream())
using (var reader = new StreamReader(stream))
using (var writer = new StreamWriter(stream))
using (var csvWriter = new CsvWriter(writer))
{
csvWriter.Configuration.QuoteNoFields = true;
csvWriter.Configuration.RegisterClassMap<TestRecordMap>();
csvWriter.WriteRecord(record);
writer.Flush();
stream.Position = 0;
csv = reader.ReadToEnd();
}
var expected = "first, column,1,string \" column,test\r\n";
Assert.AreEqual(expected, csv);
}
[TestMethod]
public void WriteHeaderTest()
{
string csv;
using (var stream = new MemoryStream())
using (var reader = new StreamReader(stream))
using (var writer = new StreamWriter(stream))
using (var csvWriter = new CsvWriter(writer))
{
csvWriter.Configuration.HasHeaderRecord = true;
csvWriter.Configuration.RegisterClassMap<TestRecordMap>();
csvWriter.WriteHeader(typeof(TestRecord));
writer.Flush();
stream.Position = 0;
csv = reader.ReadToEnd();
}
const string Expected = "FirstColumn,Int Column,StringColumn,TypeConvertedColumn\r\n";
Assert.AreEqual(Expected, csv);
}
[TestMethod]
public void WriteHeaderFailsIfHasHeaderRecordIsNotConfiguredTest()
{
using (var stream = new MemoryStream())
using (var writer = new StreamWriter(stream))
using (var csvWriter = new CsvWriter(writer))
{
csvWriter.Configuration.HasHeaderRecord = false;
csvWriter.Configuration.RegisterClassMap<TestRecordMap>();
try
{
csvWriter.WriteHeader(typeof(TestRecord));
Assert.Fail();
}
catch (CsvWriterException)
{
}
}
}
[TestMethod]
public void WriteRecordWithDelimiterInFieldTest()
{
using (var stream = new MemoryStream())
using (var reader = new StreamReader(stream))
using (var writer = new StreamWriter(stream))
using (var csv = new CsvWriter(writer))
{
var record = new TestSinglePropertyRecord
{
Name = "one,two"
};
csv.WriteRecord(record);
writer.Flush();
stream.Position = 0;
var text = reader.ReadToEnd();
Assert.AreEqual("\"one,two\"\r\n", text);
}
}
[TestMethod]
public void WriteRecordWithQuoteInFieldTest()
{
using (var stream = new MemoryStream())
using (var reader = new StreamReader(stream))
using (var writer = new StreamWriter(stream))
using (var csv = new CsvWriter(writer))
{
var record = new TestSinglePropertyRecord
{
Name = "one\"two"
};
csv.WriteRecord(record);
writer.Flush();
stream.Position = 0;
var text = reader.ReadToEnd();
Assert.AreEqual("\"one\"\"two\"\r\n", text);
}
}
[TestMethod]
public void WriteRecordWithQuoteAllFieldsOnAndDelimiterInFieldTest()
{
using (var stream = new MemoryStream())
using (var reader = new StreamReader(stream))
using (var writer = new StreamWriter(stream))
using (var csv = new CsvWriter(writer))
{
csv.Configuration.QuoteAllFields = true;
var record = new TestSinglePropertyRecord
{
Name = "one,two"
};
csv.WriteRecord(record);
writer.Flush();
stream.Position = 0;
var text = reader.ReadToEnd();
Assert.AreEqual("\"one,two\"\r\n", text);
}
}
[TestMethod]
public void WriteRecordWithQuoteAllFieldsOnAndQuoteInFieldTest()
{
using (var stream = new MemoryStream())
using (var reader = new StreamReader(stream))
using (var writer = new StreamWriter(stream))
using (var csv = new CsvWriter(writer))
{
csv.Configuration.QuoteAllFields = true;
var record = new TestSinglePropertyRecord
{
Name = "one\"two"
};
csv.WriteRecord(record);
writer.Flush();
stream.Position = 0;
var text = reader.ReadToEnd();
Assert.AreEqual("\"one\"\"two\"\r\n", text);
}
}
[TestMethod]
public void WriteRecordsWithInvariantCultureTest()
{
using (var stream = new MemoryStream())
using (var reader = new StreamReader(stream))
using (var writer = new StreamWriter(stream))
using (var csv = new CsvWriter(writer))
{
csv.Configuration.CultureInfo = CultureInfo.InvariantCulture;
csv.Configuration.RegisterClassMap<TestRecordMap>();
var record = new TestRecord
{
IntColumn = 1,
FirstColumn = "first column",
IgnoredColumn = "ignored column",
StringColumn = "string column",
};
csv.WriteRecord(record);
writer.Flush();
stream.Position = 0;
var csvString = reader.ReadToEnd();
}
}
[TestMethod]
public void WriteNoGetterTest()
{
using (var stream = new MemoryStream())
using (var reader = new StreamReader(stream))
using (var writer = new StreamWriter(stream))
using (var csv = new CsvWriter(writer))
{
var list = new List<TestPrivateGet>
{
new TestPrivateGet
{
Id = 1,
Name = "one"
}
};
csv.WriteRecords(list);
writer.Flush();
stream.Position = 0;
var data = reader.ReadToEnd();
var expected = new StringBuilder();
expected.AppendLine("Id");
expected.AppendLine("1");
Assert.AreEqual(expected.ToString(), data);
}
}
[TestMethod]
public void WriteDynamicTest()
{
using (var stream = new MemoryStream())
using (var reader = new StreamReader(stream))
using (var writer = new StreamWriter(stream))
using (var csv = new CsvWriter(writer))
{
csv.WriteRecord(new { Id = 1, Name = "one" });
writer.Flush();
stream.Position = 0;
var text = reader.ReadToEnd();
Assert.AreEqual("1,one\r\n", text);
}
}
[TestMethod]
public void WritePrimitivesRecordsHasHeaderTrueTest()
{
using (var stream = new MemoryStream())
using (var reader = new StreamReader(stream))
using (var writer = new StreamWriter(stream))
using (var csv = new CsvWriter(writer))
{
csv.Configuration.HasHeaderRecord = true;
var list = new List<int> { 1, 2, 3 };
csv.WriteRecords(list);
writer.Flush();
stream.Position = 0;
var text = reader.ReadToEnd();
Assert.AreEqual("1\r\n2\r\n3\r\n", text);
}
}
[TestMethod]
public void WritePrimitivesRecordsHasHeaderFalseTest()
{
using (var stream = new MemoryStream())
using (var reader = new StreamReader(stream))
using (var writer = new StreamWriter(stream))
using (var csv = new CsvWriter(writer))
{
csv.Configuration.HasHeaderRecord = false;
var list = new List<int> { 1, 2, 3 };
csv.WriteRecords(list);
writer.Flush();
stream.Position = 0;
var text = reader.ReadToEnd();
Assert.AreEqual("1\r\n2\r\n3\r\n", text);
}
}
[TestMethod]
public void WriteStructRecordsTest()
{
using (var stream = new MemoryStream())
using (var reader = new StreamReader(stream))
using (var writer = new StreamWriter(stream))
using (var csv = new CsvWriter(writer))
{
var list = new List<TestStruct>
{
new TestStruct { Id = 1, Name = "one" },
new TestStruct { Id = 2, Name = "two" },
};
csv.WriteRecords(list);
writer.Flush();
stream.Position = 0;
var text = reader.ReadToEnd();
Assert.AreEqual("Id,Name\r\n1,one\r\n2,two\r\n", text);
}
}
[TestMethod]
public void WriteStructReferenceRecordsTest()
{
var list = new List<TestStructParent>
{
new TestStructParent
{
Test = new TestStruct
{
Id = 1,
Name = "one",
},
},
};
using (var stream = new MemoryStream())
using (var reader = new StreamReader(stream))
using (var writer = new StreamWriter(stream))
using (var csv = new CsvWriter(writer))
{
csv.Configuration.RegisterClassMap<TestStructParentMap>();
csv.WriteRecords(list);
writer.Flush();
stream.Position = 0;
var data = reader.ReadToEnd();
Assert.AreEqual("Id,Name\r\n1,one\r\n", data);
}
}
[TestMethod]
public void WriteNestedHeadersTest()
{
var list = new List<Person>
{
new Person
{
FirstName = "first",
LastName = "last",
HomeAddress = new Address
{
City = "home city",
State = "home state",
Street = "home street",
Zip = "home zip",
},
WorkAddress = new Address
{
City = "work city",
State = "work state",
Street = "work street",
Zip = "work zip",
},
},
};
using (var stream = new MemoryStream())
using (var reader = new StreamReader(stream))
using (var writer = new StreamWriter(stream))
using (var csv = new CsvWriter(writer))
{
csv.Configuration.PrefixReferenceHeaders = true;
csv.WriteRecords(list);
writer.Flush();
stream.Position = 0;
var text = reader.ReadToEnd();
var expected = new StringBuilder();
expected.AppendLine("FirstName,LastName,HomeAddress.Street,HomeAddress.City,HomeAddress.State,HomeAddress.Zip,WorkAddress.Street,WorkAddress.City,WorkAddress.State,WorkAddress.Zip");
expected.AppendLine("first,last,home street,home city,home state,home zip,work street,work city,work state,work zip");
Assert.AreEqual(expected.ToString(), text);
}
}
[TestMethod]
public void WriteEmptyListTest()
{
using (var stream = new MemoryStream())
using (var reader = new StreamReader(stream))
using (var writer = new StreamWriter(stream))
using (var csv = new CsvWriter(writer))
{
var list = new List<TestRecord>();
csv.WriteRecords(list);
writer.Flush();
stream.Position = 0;
var data = reader.ReadToEnd();
Assert.IsFalse(string.IsNullOrWhiteSpace(data));
}
}
[TestMethod]
public void ClassWithStaticAutoMappingTest()
{
using( var stream = new MemoryStream() )
using( var reader = new StreamReader( stream ) )
using( var writer = new StreamWriter( stream ) )
using( var csv = new CsvWriter( writer ) )
{
TestWithStatic.Name = "one";
var records = new List<TestWithStatic>
{
new TestWithStatic
{
Id = 1
},
};
csv.WriteRecords( records );
}
}
[TestMethod]
public void ClassWithStaticUsingMappingTest()
{
using( var stream = new MemoryStream() )
using( var reader = new StreamReader( stream ) )
using( var writer = new StreamWriter( stream ) )
using( var csv = new CsvWriter( writer ) )
{
csv.Configuration.RegisterClassMap<TestWithStaticMap>();
TestWithStatic.Name = "one";
var records = new List<TestWithStatic>
{
new TestWithStatic
{
Id = 1
},
};
csv.WriteRecords( records );
}
}
#if !PCL
[TestMethod]
public void WriteDynamicListTest()
{
using( var stream = new MemoryStream() )
using( var reader = new StreamReader( stream ) )
using( var writer = new StreamWriter( stream ) )
using( var csv = new CsvWriter( writer ) )
{
var list = new List<dynamic>();
dynamic record = new { Id = 1, Name = "one" };
list.Add( record );
csv.WriteRecords( list );
writer.Flush();
stream.Position = 0;
var text = reader.ReadToEnd();
Assert.AreEqual( "Id,Name\r\n1,one\r\n", text );
}
}
// TODO: Make reader/writer work with expando objects.
[Ignore]
[TestMethod]
public void WriteExpandoListTest()
{
using( var stream = new MemoryStream() )
using( var reader = new StreamReader( stream ) )
using( var writer = new StreamWriter( stream ) )
using( var csv = new CsvWriter( writer ) )
{
var list = new List<dynamic>();
dynamic record = new ExpandoObject();
record.Id = 1;
record.Name = "one";
list.Add( record );
csv.WriteRecords( list );
writer.Flush();
stream.Position = 0;
var text = reader.ReadToEnd();
Assert.AreEqual( "Id,Name\r\n1,one\r\n", text );
}
}
#endif
private class TestWithStatic
{
public int Id { get; set; }
public static string Name { get; set; }
}
private sealed class TestWithStaticMap : CsvClassMap<TestWithStatic>
{
public TestWithStaticMap()
{
Map( m => m.Id );
}
}
private class TestStructParent
{
public TestStruct Test { get; set; }
}
private sealed class TestStructParentMap : CsvClassMap<TestStructParent>
{
public TestStructParentMap()
{
References<TestStructMap>(m => m.Test);
}
}
private struct TestStruct
{
public int Id { get; set; }
public string Name { get; set; }
}
private sealed class TestStructMap : CsvClassMap<TestStruct>
{
public TestStructMap()
{
Map(m => m.Id);
Map(m => m.Name);
}
}
private class TestPrivateGet
{
public int Id { get; set; }
public string Name { private get; set; }
}
private class TestSinglePropertyRecord
{
public string Name { get; set; }
}
private class TestRecord
{
public int IntColumn { get; set; }
public string StringColumn { get; set; }
public string IgnoredColumn { get; set; }
public string FirstColumn { get; set; }
public string TypeConvertedColumn { get; set; }
}
private sealed class TestRecordMap : CsvClassMap<TestRecord>
{
public TestRecordMap()
{
Map(m => m.IntColumn).Name("Int Column").Index(1).TypeConverter<Int32Converter>();
Map(m => m.StringColumn);
Map(m => m.FirstColumn).Index(0);
Map(m => m.TypeConvertedColumn).TypeConverter<TestTypeConverter>();
}
}
private class TestRecordNoIndexes
{
public int IntColumn { get; set; }
public string StringColumn { get; set; }
public string IgnoredColumn { get; set; }
public string FirstColumn { get; set; }
public string TypeConvertedColumn { get; set; }
}
private sealed class TestRecordNoIndexesMap : CsvClassMap<TestRecordNoIndexes>
{
public TestRecordNoIndexesMap()
{
Map(m => m.IntColumn).Name("Int Column").TypeConverter<Int32Converter>();
Map(m => m.StringColumn);
Map(m => m.FirstColumn);
Map(m => m.TypeConvertedColumn).TypeConverter<TestTypeConverter>();
}
}
private class TestTypeConverter : ITypeConverter
{
public string ConvertToString(TypeConverterOptions options, object value)
{
return "test";
}
public object ConvertFromString(TypeConverterOptions options, string text)
{
throw new NotImplementedException();
}
public bool CanConvertFrom(Type type)
{
throw new NotImplementedException();
}
public bool CanConvertTo(Type type)
{
return true;
}
}
private class Person
{
public string FirstName { get; set; }
public string LastName { get; set; }
public Address HomeAddress { get; set; }
public Address WorkAddress { get; set; }
}
private class Address
{
public string Street { get; set; }
public string City { get; set; }
public string State { get; set; }
public string Zip { get; set; }
}
private sealed class PersonMap : CsvClassMap<Person>
{
public PersonMap()
{
Map(m => m.FirstName);
Map(m => m.LastName);
References<HomeAddressMap>(m => m.HomeAddress);
References<WorkAddressMap>(m => m.WorkAddress);
}
}
private sealed class HomeAddressMap : CsvClassMap<Address>
{
public HomeAddressMap()
{
Map(m => m.Street).Name("HomeStreet");
Map(m => m.City).Name("HomeCity");
Map(m => m.State).Name("HomeState");
Map(m => m.Zip).Name("HomeZip");
}
}
private sealed class WorkAddressMap : CsvClassMap<Address>
{
public WorkAddressMap()
{
Map(m => m.Street).Name("WorkStreet");
Map(m => m.City).Name("WorkCity");
Map(m => m.State).Name("WorkState");
Map(m => m.Zip).Name("WorkZip");
}
}
}
}
| KeesDijk/CsvHelper | src/CsvHelper.Tests/CsvWriterTests.cs | C# | apache-2.0 | 32,309 | [
30522,
1013,
1013,
9385,
2268,
1011,
2325,
6498,
2485,
1998,
16884,
1013,
1013,
2023,
5371,
2003,
1037,
2112,
1997,
20116,
2615,
16001,
4842,
1998,
2003,
7037,
7000,
2104,
5796,
1011,
20228,
1998,
15895,
1016,
1012,
1014,
1012,
1013,
1013,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
#
# OpenSSL/crypto/rc4/Makefile
#
DIR= rc4
TOP= ../..
CC= cc
CPP= $(CC) -E
INCLUDES=
CFLAG=-g
AR= ar r
RC4_ENC=rc4_enc.o rc4_skey.o
CFLAGS= $(INCLUDES) $(CFLAG)
ASFLAGS= $(INCLUDES) $(ASFLAG)
AFLAGS= $(ASFLAGS)
GENERAL=Makefile
TEST=rc4test.c
APPS=
LIB=$(TOP)/libcrypto.a
LIBSRC=rc4_skey.c rc4_enc.c rc4_utl.c
LIBOBJ=$(RC4_ENC) rc4_utl.o
SRC= $(LIBSRC)
EXHEADER= rc4.h
HEADER= $(EXHEADER) rc4_locl.h
ALL= $(GENERAL) $(SRC) $(HEADER)
top:
(cd ../..; $(MAKE) DIRS=crypto SDIRS=$(DIR) sub_all)
all: lib
lib: $(LIBOBJ)
$(AR) $(LIB) $(LIBOBJ)
$(RANLIB) $(LIB) || echo Never mind.
@touch lib
rc4-586.s: asm/rc4-586.pl ../perlasm/x86asm.pl
$(PERL) asm/rc4-586.pl $(PERLASM_SCHEME) $(CFLAGS) $(PROCESSOR) > $@
rc4-x86_64.s: asm/rc4-x86_64.pl
$(PERL) asm/rc4-x86_64.pl $(PERLASM_SCHEME) > $@
rc4-md5-x86_64.s: asm/rc4-md5-x86_64.pl
$(PERL) asm/rc4-md5-x86_64.pl $(PERLASM_SCHEME) > $@
rc4-ia64.S: asm/rc4-ia64.pl
$(PERL) asm/rc4-ia64.pl $(CFLAGS) > $@
rc4-parisc.s: asm/rc4-parisc.pl
$(PERL) asm/rc4-parisc.pl $(PERLASM_SCHEME) $@
rc4-ia64.s: rc4-ia64.S
@case `awk '/^#define RC4_INT/{print$$NF}' $(TOP)/include/openssl/opensslconf.h` in \
int) set -x; $(CC) $(CFLAGS) -DSZ=4 -E rc4-ia64.S > $@ ;; \
char) set -x; $(CC) $(CFLAGS) -DSZ=1 -E rc4-ia64.S > $@ ;; \
*) exit 1 ;; \
esac
# GNU make "catch all"
rc4-%.s: asm/rc4-%.pl; $(PERL) $< $(PERLASM_SCHEME) $@
files:
$(PERL) $(TOP)/util/files.pl "RC4_ENC=$(RC4_ENC)" Makefile >> $(TOP)/MINFO
links:
@$(PERL) $(TOP)/util/mklink.pl ../../include/openssl $(EXHEADER)
@$(PERL) $(TOP)/util/mklink.pl ../../test $(TEST)
@$(PERL) $(TOP)/util/mklink.pl ../../apps $(APPS)
install:
@[ -n "$(INSTALLTOP)" ] # should be set by top Makefile...
@headerlist="$(EXHEADER)"; for i in $$headerlist ; \
do \
(cp $$i $(INSTALL_PREFIX)$(INSTALLTOP)/include/openssl/$$i; \
chmod 644 $(INSTALL_PREFIX)$(INSTALLTOP)/include/openssl/$$i ); \
done;
tags:
ctags $(SRC)
tests:
lint:
lint -DLINT $(INCLUDES) $(SRC)>fluff
update: depend
depend:
@[ -n "$(MAKEDEPEND)" ] # should be set by upper Makefile...
$(MAKEDEPEND) -- $(CFLAG) $(INCLUDES) $(DEPFLAG) -- $(PROGS) $(LIBSRC)
dclean:
$(PERL) -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new
mv -f Makefile.new $(MAKEFILE)
clean:
rm -f *.s *.S *.o *.obj lib tags core .pure .nfs* *.old *.bak fluff
# DO NOT DELETE THIS LINE -- make depend depends on it.
rc4_enc.o: ../../e_os.h ../../include/openssl/bio.h
rc4_enc.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
rc4_enc.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
rc4_enc.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
rc4_enc.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
rc4_enc.o: ../../include/openssl/rc4.h ../../include/openssl/safestack.h
rc4_enc.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
rc4_enc.o: ../cryptlib.h rc4_enc.c rc4_locl.h
rc4_skey.o: ../../e_os.h ../../include/openssl/bio.h
rc4_skey.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
rc4_skey.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
rc4_skey.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
rc4_skey.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
rc4_skey.o: ../../include/openssl/rc4.h ../../include/openssl/safestack.h
rc4_skey.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
rc4_skey.o: ../cryptlib.h rc4_locl.h rc4_skey.c
rc4_utl.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
rc4_utl.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
rc4_utl.o: ../../include/openssl/ossl_typ.h ../../include/openssl/rc4.h
rc4_utl.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
rc4_utl.o: ../../include/openssl/symhacks.h rc4_utl.c
| LomoX-Offical/nginx-openresty-windows | src/nginx/objs/lib_x64/openssl/crypto/rc4/Makefile | Makefile | bsd-2-clause | 3,862 | [
30522,
1001,
1001,
7480,
14540,
1013,
19888,
2080,
1013,
22110,
2549,
1013,
2191,
8873,
2571,
1001,
16101,
1027,
22110,
2549,
2327,
1027,
1012,
1012,
1013,
1012,
1012,
10507,
1027,
10507,
18133,
2361,
1027,
1002,
1006,
10507,
1007,
1011,
10... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
/* Copyright (c) 2003-2014 Dovecot authors, see the included COPYING file */
#include "lib.h"
#include "read-full.h"
#include <unistd.h>
int read_full(int fd, void *data, size_t size)
{
ssize_t ret;
while (size > 0) {
ret = read(fd, data, size < SSIZE_T_MAX ? size : SSIZE_T_MAX);
if (ret <= 0)
return ret;
data = PTR_OFFSET(data, ret);
size -= ret;
}
return 1;
}
int pread_full(int fd, void *data, size_t size, off_t offset)
{
ssize_t ret;
while (size > 0) {
ret = pread(fd, data, size < SSIZE_T_MAX ?
size : SSIZE_T_MAX, offset);
if (ret <= 0)
return ret;
data = PTR_OFFSET(data, ret);
size -= ret;
offset += ret;
}
return 1;
}
| jwm/dovecot-notmuch | src/lib/read-full.c | C | mit | 679 | [
30522,
1013,
1008,
9385,
1006,
1039,
1007,
2494,
1011,
2297,
10855,
24310,
6048,
1010,
2156,
1996,
2443,
24731,
5371,
1008,
1013,
1001,
2421,
1000,
5622,
2497,
1012,
1044,
1000,
1001,
2421,
1000,
3191,
1011,
2440,
1012,
1044,
1000,
1001,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
import * as React from './dfvReact'
import { dfvFront } from "./dfvFront";
export interface PopWindowPara {
/**
* 是否不覆盖全屏
*/
notCover?: boolean;
/**
* 是否显示红色背景的错误提示框
*/
isErr?: boolean;
/**
* 自动关闭时间,为0则不自动关闭
*/
closeTime?: number;
}
export class dfvWindow {
//主窗口
private dialog: HTMLDivElement | undefined;
//cover层
private divCover: HTMLDivElement | undefined;
//内容层
private divContent: HTMLDivElement | undefined;
static coverZ = 999;
constructor() {
dfvWindow.coverZ++;
}
/**
* 添加一个黑色半透明的遮盖层
* @returns {dfvWindow}
*/
addCover() {
if (!this.divCover) {
this.divCover = document.createElement("div");
this.divCover.className = "cover_div cover_black"
this.divCover.style.zIndex = dfvWindow.coverZ + "";
document.body.appendChild(this.divCover);
}
return this;
}
/**
* 处理PopWindowPara参数
* @param para
* @returns {dfvWindow}
*/
procParas(para: PopWindowPara) {
if (para && para.closeTime! > 0) {
this.autoClose(para.closeTime)
}
this.isError = para.isErr!!;
if (!para.notCover)
this.addCover();
return this;
}
/**
* 是否显示红色错误提示样式
* @type {boolean}
*/
isError = false;
/**
* 显示窗口
* @param title 标题
* @param content 内容
* @returns {dfvWindow}
*/
public show(title: string | HTMLElement, content?: string | HTMLElement | null) {
if (this.dialog)
return this;
let c1 = this.isError ? "ba_tra_red" : "ba_tra_blue"
let c2 = this.isError ? "icon_err" : "icon_close"
this.dialog =
<div className={"pop_border anim_in " + c1}>
{
this.divContent =
<div className="pop_cont">
<div className="vmid pad5">
{title}
</div>
{content ? <div style="margin-top: 10px">{content}</div> : null}
</div>
}
<div className="absol_close">
<tt onclick={() => this.onButtonCancelClick()}
className={"rotate_hover " + c2} />
</div>
</div>
this.dialog!.style.zIndex = (dfvWindow.coverZ + 1) + "";
document.body.appendChild(this.dialog!);
this.reSize();
this.resizeTime = setInterval(this.reSize, 200);
return this;
}
/**
* 显示带一个【确定】按钮的窗口
* @param title
* @param content
* @param onOk 按钮回调
* @returns {dfvWindow}
*/
public showWithOk(title: string | HTMLElement,
content: string | HTMLElement | null,
onOk: (e: HTMLElement) => void) {
this.show(title, this.okWindow(content, onOk))
return this;
}
/**
* 关闭按钮点击事件回调
*/
onButtonCancelClick = () => {
this.close();
}
/**
* 将窗口设为自动关闭
* @param time 自动关闭时间:毫秒
* @returns {dfvWindow}
*/
autoClose(time: number = 3000) {
setTimeout(() => {
this.close()
}, time);
return this;
}
/**
* 关闭窗口
*/
close = () => {
try {
clearInterval(this.resizeTime);
//窗口已关闭
if (!this.divContent || !this.dialog) {
return;
}
if (this.divCover) {
try {
document.body.removeChild(this.divCover);
} catch (e) {
}
}
this.divCover = null as any;
this.divContent = null as any;
let dia = this.dialog;
this.dialog = undefined;
if (window.history.pushState != null) {
dia.className += " anim_out";
setTimeout(() => {
//窗口已关闭
try {
document.body.removeChild(dia);
} catch (e) {
}
}, 300)
} else {
try {
document.body.removeChild(dia);
} catch (e) {
}
}
} catch (e) {
dfvFront.onCatchError(e)
}
}
/**
* 修正窗口大小与位置
*/
private reSize = () => {
if (!this.dialog || !this.divContent)
return;
if (this.dialog.offsetWidth < document.documentElement!.clientWidth) {
let w = document.documentElement!.clientWidth - this.dialog.offsetWidth;
this.dialog.style.marginLeft = ((w >> 1) & (~3)) + "px";
}
this.divContent.style.maxWidth = document.documentElement!.clientWidth - 40 + "px";
if (this.dialog.offsetHeight < document.documentElement!.clientHeight) {
let h = (Math.floor((document.documentElement!.clientHeight - this.dialog.offsetHeight) / 3));
h = h & (~3);
this.dialog.style.marginTop = h + "px";
}
this.divContent.style.maxHeight = document.documentElement!.clientHeight - 45 + "px";
}
private resizeTime: any;
/**
* 确定按钮的文字
* @type {string}
*/
buttonOkText = "确定";
private okWindow(content: string | HTMLElement | null, onOk: (e: HTMLElement) => void) {
return (
<div>
<div>
{content}
</div>
<div class="h_m">
<button class="button_blue pad6-12 mar5t font_0 bold" onclick={e => onOk(e.currentTarget)}>
{this.buttonOkText}
</button>
</div>
</div>
)
}
} | rxaa/dfv | src/public/dfvWindow.tsx | TypeScript | mit | 6,167 | [
30522,
12324,
1008,
2004,
10509,
2013,
1005,
1012,
1013,
1040,
2546,
12229,
18908,
1005,
12324,
1063,
1040,
2546,
2615,
12792,
1065,
2013,
1000,
1012,
1013,
1040,
2546,
2615,
12792,
1000,
1025,
9167,
8278,
3769,
11101,
5004,
28689,
1063,
10... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
/* ShipManager.js
KC3改 Ship Manager
Managesship roster and does indexing for data access.
Saves and loads list to and from localStorage
*/
(function(){
"use strict";
window.KC3ShipManager = {
list: {},
max: 100,
pendingShipNum: 0,
// Get a specific ship by ID
get :function( rosterId ){
// console.log("getting ship", rosterId, this.list["x"+rosterId]);
return this.list["x"+rosterId] || (new KC3Ship());
},
// Count number of ships
count :function(){
return Object.size(this.list) + this.pendingShipNum;
},
// Add or replace a ship on the list
add :function(data){
var didFlee = false;
if(typeof data.api_id != "undefined"){
if (typeof this.list["x"+data.api_id] !== "undefined") {
didFlee = this.list["x"+data.api_id].didFlee;
}
this.list["x"+data.api_id] = new KC3Ship(data);
this.list["x"+data.api_id].didFlee = didFlee;
}else if(typeof data.rosterId != "undefined"){
if (typeof this.list["x"+data.rosterId] !== "undefined") {
didFlee = this.list["x"+data.rosterId].didFlee;
}
this.list["x"+data.rosterId] = new KC3Ship(data);
this.list["x"+data.rosterId].didFlee = didFlee;
}
},
// Mass set multiple ships
set :function(data){
var ctr;
for(ctr in data){
if(!!data[ctr]){
this.add(data[ctr]);
}
}
this.save();
},
// Remove ship from the list, scrapped, mod-fodded, or sunk
remove :function( rosterId ){
console.log("removing ship", rosterId);
var thisShip = this.list["x"+rosterId];
if(thisShip != "undefined"){
// initializing for fleet sanitizing of zombie ships
var
flatShips = PlayerManager.fleets
.map(function(x){ return x.ships; })
.reduce(function(x,y){ return x.concat(y); }),
shipTargetOnFleet = flatShips.indexOf(Number(rosterId)), // check from which fleet
shipTargetFleetID = Math.floor(shipTargetOnFleet/6);
// check whether the designated ship is on fleet or not
if(shipTargetOnFleet >= 0){
PlayerManager.fleets[shipTargetFleetID].discard(rosterId);
}
// remove any equipments from her
for(var gctr in thisShip.items){
if(thisShip.items[gctr] > -1){
KC3GearManager.remove( thisShip.items[gctr] );
}
}
delete this.list["x"+rosterId];
this.save();
KC3GearManager.save();
}
},
// Show JSON string of the list for debugging purposes
json: function(){
console.log(JSON.stringify(this.list));
},
// Save ship list onto local storage
clear: function(){
this.list = {};
},
// Save ship list onto local storage
save: function(){
localStorage.ships = JSON.stringify(this.list);
},
// Load from storage and add each one to manager list
load: function(){
if(typeof localStorage.ships != "undefined"){
this.clear();
var ShipList = JSON.parse(localStorage.ships);
for(var ctr in ShipList){
this.add( ShipList[ctr] );
}
return true;
}
return false;
}
};
})(); | ethrundr/KC3Kai | src/library/managers/ShipManager.js | JavaScript | mit | 3,115 | [
30522,
1013,
1008,
2911,
24805,
4590,
1012,
1046,
2015,
21117,
2509,
100,
2911,
3208,
9020,
9650,
9238,
1998,
2515,
5950,
2075,
2005,
2951,
3229,
1012,
13169,
1998,
15665,
2862,
2000,
1998,
2013,
10575,
4263,
4270,
1008,
1013,
1006,
3853,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
---
author: admin
comments: true
date: 2011-03-22 14:16:57+00:00
layout: post
slug: objectivec_callback
title: Objective-CでCallback
categories: プログラミング
tags: Objective-C
---
イベントディスパッチャーを使ってイベント処理する方法について。
今までプロパティやセッターやらで処理してたけど、
イベント処理の方がセンスがよさそうなのでそっちでやる。
Callbackの受け取り側では以下を定義
{% highlight objectivec %}
//ViewDidLoadなりの中で初期化するときに呼んでやる
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(recvCallback:) name:@"MyEvent" object:nil];
//実際にコールバックを受け取る部分
- (void) recvCallback: (NSNotification*) note{
NSLog(@"recvCallback");
NSLog(@"%@", [note object]);
NSLog(@"recvCallback end");
}
{% endhighlight %}
Callbackの送り側では以下を実行する
{% highlight objectivec %}
NSNotificationCenter *center = [NSNotificationCenter defaultCenter];
// イベントをポスト。argはイベントハンドラに渡す引数
[center postNotificationName:@"MyEvent" object: @"hoge"];
{% endhighlight %}
[サンプル](/img/2011/03/SimpleCallback.zip)
| nakakura/nakakura.github.io | _posts/2011/03/2011-03-22-objectivec_callback.md | Markdown | mit | 1,281 | [
30522,
1011,
1011,
1011,
3166,
1024,
4748,
10020,
7928,
1024,
2995,
3058,
1024,
2249,
1011,
6021,
1011,
2570,
2403,
1024,
2385,
1024,
5401,
1009,
4002,
1024,
4002,
9621,
1024,
2695,
23667,
1024,
7863,
2278,
1035,
2655,
5963,
2516,
1024,
7... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
// This file auto generated by plugin for ida pro. Generated code only for x64. Please, dont change manually
#pragma once
#include <common/common.h>
#include <_ccrfg_detect_alret.hpp>
START_ATF_NAMESPACE
namespace Info
{
using _ccrfg_detect_alretsize2_ptr = int (WINAPIV*)(struct _ccrfg_detect_alret*);
using _ccrfg_detect_alretsize2_clbk = int (WINAPIV*)(struct _ccrfg_detect_alret*, _ccrfg_detect_alretsize2_ptr);
}; // end namespace Info
END_ATF_NAMESPACE
| goodwinxp/Yorozuya | library/ATF/_ccrfg_detect_alretInfo.hpp | C++ | mit | 490 | [
30522,
1013,
1013,
2023,
5371,
8285,
7013,
2011,
13354,
2378,
2005,
16096,
4013,
1012,
7013,
3642,
2069,
2005,
1060,
21084,
1012,
3531,
1010,
2123,
2102,
2689,
21118,
1001,
10975,
8490,
2863,
2320,
1001,
2421,
1026,
2691,
1013,
2691,
1012,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
package org.hl7.v3;
import javax.xml.bind.annotation.XmlEnum;
import javax.xml.bind.annotation.XmlType;
/**
* <p>DataTypePointInTimeのJavaクラス。
*
* <p>次のスキーマ・フラグメントは、このクラス内に含まれる予期されるコンテンツを指定します。
* <p>
* <pre>
* <simpleType name="DataTypePointInTime">
* <restriction base="{urn:hl7-org:v3}cs">
* <enumeration value="TS"/>
* </restriction>
* </simpleType>
* </pre>
*
*/
@XmlType(name = "DataTypePointInTime")
@XmlEnum
public enum DataTypePointInTime {
TS;
public String value() {
return name();
}
public static DataTypePointInTime fromValue(String v) {
return valueOf(v);
}
}
| ricecakesoftware/CommunityMedicalLink | ricecakesoftware.communitymedicallink.hl7/src/org/hl7/v3/DataTypePointInTime.java | Java | gpl-3.0 | 786 | [
30522,
7427,
8917,
1012,
1044,
2140,
2581,
1012,
1058,
2509,
1025,
12324,
9262,
2595,
1012,
20950,
1012,
14187,
1012,
5754,
17287,
3508,
1012,
20950,
2368,
2819,
1025,
12324,
9262,
2595,
1012,
20950,
1012,
14187,
1012,
5754,
17287,
3508,
10... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
/**************************************************************************
*
* Gluewine Console Module
*
* Copyright (C) 2013 FKS bvba http://www.fks.be/
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
***************************************************************************/
package org.gluewine.console;
/**
* A reponse that failed due to a syntax exception.
*
* @author fks/Serge de Schaetzen
*
*/
public class SyntaxResponse extends Response
{
// ===========================================================================
/** The serial uid. */
private static final long serialVersionUID = -7101539852928081970L;
/** The command that failed. */
private CLICommand cmd = null;
// ===========================================================================
/**
* Creates an instance.
*
* @param output The output of the command.
* @param cmd The command that failed.
* @param routed Whether the output is routed or not.
* @param batch Whether the command was entered from batch mode.
* @param interactive Whether the option values were entered interactively.
*/
public SyntaxResponse(String output, CLICommand cmd, boolean routed, boolean batch, boolean interactive)
{
super(output, routed, batch, interactive);
this.cmd = cmd;
}
// ===========================================================================
/**
* Returns the command that failed.
*
* @return The command that failed.
*/
public CLICommand getCommand()
{
return cmd;
}
}
| sergeds/Gluewine | imp/src/java/org/gluewine/console/SyntaxResponse.java | Java | apache-2.0 | 2,122 | [
30522,
1013,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
100... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
<?php
namespace Drush\Boot;
use Consolidation\AnnotatedCommand\AnnotationData;
use Drush\Log\DrushLog;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Drupal\Core\DrupalKernel;
use Drush\Drush;
use Drush\Drupal\DrushServiceModifier;
use Drush\Log\LogLevel;
class DrupalBoot8 extends DrupalBoot implements AutoloaderAwareInterface
{
use AutoloaderAwareTrait;
/**
* @var \Drupal\Core\DrupalKernelInterface
*/
protected $kernel;
/**
* @var \Symfony\Component\HttpFoundation\Request
*/
protected $request;
/**
* @return \Symfony\Component\HttpFoundation\Request
*/
public function getRequest()
{
return $this->request;
}
/**
* @param \Symfony\Component\HttpFoundation\Request $request
*/
public function setRequest($request)
{
$this->request = $request;
}
/**
* @return \Drupal\Core\DrupalKernelInterface
*/
public function getKernel()
{
return $this->kernel;
}
public function validRoot($path)
{
if (!empty($path) && is_dir($path) && file_exists($path . '/autoload.php')) {
// Additional check for the presence of core/composer.json to
// grant it is not a Drupal 7 site with a base folder named "core".
$candidate = 'core/includes/common.inc';
if (file_exists($path . '/' . $candidate) && file_exists($path . '/core/core.services.yml')) {
if (file_exists($path . '/core/misc/drupal.js') || file_exists($path . '/core/assets/js/drupal.js')) {
return $candidate;
}
}
}
}
public function getVersion($drupal_root)
{
// Are the class constants available?
if (!$this->hasAutoloader()) {
throw new \Exception('Cannot access Drupal 8 class constants - Drupal autoloader not loaded yet.');
}
// Drush depends on bootstrap being loaded at this point.
require_once $drupal_root .'/core/includes/bootstrap.inc';
if (defined('\Drupal::VERSION')) {
return \Drupal::VERSION;
}
}
public function confPath($require_settings = true, $reset = false)
{
if (\Drupal::hasService('kernel')) {
$site_path = \Drupal::service('kernel')->getSitePath();
}
if (!isset($site_path) || empty($site_path)) {
$site_path = DrupalKernel::findSitePath($this->getRequest(), $require_settings);
}
return $site_path;
}
public function addLogger()
{
// Provide a logger which sends
// output to drush_log(). This should catch every message logged through every
// channel.
$container = \Drupal::getContainer();
$parser = $container->get('logger.log_message_parser');
$drushLogger = Drush::logger();
$logger = new DrushLog($parser, $drushLogger);
$container->get('logger.factory')->addLogger($logger);
}
public function bootstrapDrupalCore($drupal_root)
{
$core = DRUPAL_ROOT . '/core';
return $core;
}
public function bootstrapDrupalSiteValidate()
{
parent::bootstrapDrupalSiteValidate();
// Normalize URI.
$uri = rtrim($this->uri, '/') . '/';
$parsed_url = parse_url($uri);
// Account for users who omit the http:// prefix.
if (empty($parsed_url['scheme'])) {
$this->uri = 'http://' . $this->uri;
$parsed_url = parse_url($this->uri);
}
$server = [
'SCRIPT_FILENAME' => getcwd() . '/index.php',
'SCRIPT_NAME' => isset($parsed_url['path']) ? $parsed_url['path'] . 'index.php' : '/index.php',
];
$request = Request::create($this->uri, 'GET', [], [], [], $server);
$this->setRequest($request);
$confPath = drush_bootstrap_value('confPath', $this->confPath(true, true));
drush_bootstrap_value('site', $request->getHttpHost());
return true;
}
public function bootstrapDrupalConfigurationValidate()
{
$conf_file = $this->confPath() . '/settings.php';
if (!file_exists($conf_file)) {
$msg = dt("Could not find a Drupal settings.php file at !file.", ['!file' => $conf_file]);
$this->logger->debug($msg);
// Cant do this because site:install deliberately bootstraps to configure without a settings.php file.
// return drush_set_error($msg);
}
return true;
}
public function bootstrapDrupalDatabaseValidate()
{
return parent::bootstrapDrupalDatabaseValidate() && $this->bootstrapDrupalDatabaseHasTable('key_value');
}
public function bootstrapDrupalDatabase()
{
// D8 omits this bootstrap level as nothing special needs to be done.
parent::bootstrapDrupalDatabase();
}
public function bootstrapDrupalConfiguration(AnnotationData $annotationData = null)
{
// Default to the standard kernel.
$kernel = Kernels::DRUPAL;
if (!empty($annotationData)) {
$kernel = $annotationData->get('kernel', Kernels::DRUPAL);
}
$classloader = $this->autoloader();
$request = $this->getRequest();
$kernel_factory = Kernels::getKernelFactory($kernel);
$allow_dumping = $kernel !== Kernels::UPDATE;
/** @var \Drupal\Core\DrupalKernelInterface kernel */
$this->kernel = $kernel_factory($request, $classloader, 'prod', $allow_dumping);
// Include Drush services in the container.
// @see Drush\Drupal\DrupalKernel::addServiceModifier()
$this->kernel->addServiceModifier(new DrushServiceModifier());
// Unset drupal error handler and restore Drush's one.
restore_error_handler();
// Disable automated cron if the module is enabled.
$GLOBALS['config']['automated_cron.settings']['interval'] = 0;
parent::bootstrapDrupalConfiguration();
}
public function bootstrapDrupalFull()
{
$this->logger->debug(dt('Start bootstrap of the Drupal Kernel.'));
$this->kernel->boot();
$this->kernel->prepareLegacyRequest($this->getRequest());
$this->logger->debug(dt('Finished bootstrap of the Drupal Kernel.'));
parent::bootstrapDrupalFull();
$this->addLogger();
// Get a list of the modules to ignore
$ignored_modules = drush_get_option_list('ignored-modules', []);
$application = Drush::getApplication();
$runner = Drush::runner();
// We have to get the service command list from the container, because
// it is constructed in an indirect way during the container initialization.
// The upshot is that the list of console commands is not available
// until after $kernel->boot() is called.
$container = \Drupal::getContainer();
// Set the command info alterers.
if ($container->has(DrushServiceModifier::DRUSH_COMMAND_INFO_ALTERER_SERVICES)) {
$serviceCommandInfoAltererlist = $container->get(DrushServiceModifier::DRUSH_COMMAND_INFO_ALTERER_SERVICES);
$commandFactory = Drush::commandFactory();
foreach ($serviceCommandInfoAltererlist->getCommandList() as $altererHandler) {
$commandFactory->addCommandInfoAlterer($altererHandler);
$this->logger->debug(dt('Commands are potentially altered in !class.', ['!class' => get_class($altererHandler)]));
}
}
$serviceCommandlist = $container->get(DrushServiceModifier::DRUSH_CONSOLE_SERVICES);
if ($container->has(DrushServiceModifier::DRUSH_CONSOLE_SERVICES)) {
foreach ($serviceCommandlist->getCommandList() as $command) {
if (!$this->commandIgnored($command, $ignored_modules)) {
$this->inflect($command);
$this->logger->log(LogLevel::DEBUG_NOTIFY, dt('Add a command: !name', ['!name' => $command->getName()]));
$application->add($command);
}
}
}
// Do the same thing with the annotation commands.
if ($container->has(DrushServiceModifier::DRUSH_COMMAND_SERVICES)) {
$serviceCommandlist = $container->get(DrushServiceModifier::DRUSH_COMMAND_SERVICES);
foreach ($serviceCommandlist->getCommandList() as $commandHandler) {
if (!$this->commandIgnored($commandHandler, $ignored_modules)) {
$this->inflect($commandHandler);
$this->logger->log(LogLevel::DEBUG_NOTIFY, dt('Add a commandfile class: !name', ['!name' => get_class($commandHandler)]));
$runner->registerCommandClass($application, $commandHandler);
}
}
}
}
public function commandIgnored($command, $ignored_modules)
{
if (empty($ignored_modules)) {
return false;
}
$ignored_regex = '#\\\\(' . implode('|', $ignored_modules) . ')\\\\#';
$class = new \ReflectionClass($command);
$commandNamespace = $class->getNamespaceName();
return preg_match($ignored_regex, $commandNamespace);
}
/**
* {@inheritdoc}
*/
public function terminate()
{
parent::terminate();
if ($this->kernel) {
$response = Response::create('');
$this->kernel->terminate($this->getRequest(), $response);
}
}
}
| eigentor/tommiblog | vendor/drush/drush/src/Boot/DrupalBoot8.php | PHP | gpl-2.0 | 9,577 | [
30522,
1026,
1029,
25718,
3415,
15327,
2852,
20668,
1032,
9573,
1025,
2224,
17439,
1032,
5754,
17287,
3064,
9006,
2386,
2094,
1032,
5754,
17287,
3508,
2850,
2696,
1025,
2224,
2852,
20668,
1032,
8833,
1032,
2852,
20668,
21197,
1025,
2224,
25... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
/*
* SonarQube
* Copyright (C) 2009-2016 SonarSource SA
* mailto:contact AT sonarsource DOT com
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package org.sonar.api.measures;
import org.apache.commons.lang.StringUtils;
import javax.annotation.Nullable;
import java.util.Collection;
/**
* An utility class to manipulate measures
*
* @since 1.10
*/
public final class MeasureUtils {
/**
* Class cannot be instantiated, it should only be access through static methods
*/
private MeasureUtils() {
}
/**
* Return true if all measures have numeric value
*
* @param measures the measures
* @return true if all measures numeric values
*/
public static boolean haveValues(Measure... measures) {
if (measures == null || measures.length == 0) {
return false;
}
for (Measure measure : measures) {
if (!hasValue(measure)) {
return false;
}
}
return true;
}
/**
* Get the value of a measure, or alternatively a default value
*
* @param measure the measure
* @param defaultValue the default value
* @return <code>defaultValue</code> if measure is null or has no values.
*/
public static Double getValue(Measure measure, @Nullable Double defaultValue) {
if (MeasureUtils.hasValue(measure)) {
return measure.getValue();
}
return defaultValue;
}
public static Long getValueAsLong(Measure measure, Long defaultValue) {
if (MeasureUtils.hasValue(measure)) {
return measure.getValue().longValue();
}
return defaultValue;
}
public static Double getVariation(Measure measure, int periodIndex) {
return getVariation(measure, periodIndex, null);
}
public static Double getVariation(Measure measure, int periodIndex, @Nullable Double defaultValue) {
Double result = null;
if (measure != null) {
result = measure.getVariation(periodIndex);
}
return result != null ? result : defaultValue;
}
public static Long getVariationAsLong(Measure measure, int periodIndex) {
return getVariationAsLong(measure, periodIndex, null);
}
public static Long getVariationAsLong(Measure measure, int periodIndex, @Nullable Long defaultValue) {
Double result = null;
if (measure != null) {
result = measure.getVariation(periodIndex);
}
return result == null ? defaultValue : Long.valueOf(result.longValue());
}
/**
* Tests if a measure has a value
*
* @param measure the measure
* @return whether the measure has a value
*/
public static boolean hasValue(Measure measure) {
return measure != null && measure.getValue() != null;
}
/**
* Tests if a measure has a data field
*
* @param measure the measure
* @return whether the measure has a data field
*/
public static boolean hasData(Measure measure) {
return measure != null && StringUtils.isNotBlank(measure.getData());
}
/**
* Sums a series of measures
*
* @param zeroIfNone whether to return 0 or null in case measures is null
* @param measures the series of measures
* @return the sum of the measure series
*/
public static Double sum(boolean zeroIfNone, Collection<Measure> measures) {
if (measures != null) {
return sum(zeroIfNone, measures.toArray(new Measure[measures.size()]));
}
return zeroIfNone(zeroIfNone);
}
/**
* Sums a series of measures
*
* @param zeroIfNone whether to return 0 or null in case measures is null
* @param measures the series of measures
* @return the sum of the measure series
*/
public static Double sum(boolean zeroIfNone, Measure... measures) {
if (measures == null) {
return zeroIfNone(zeroIfNone);
}
Double sum = 0d;
boolean hasValue = false;
for (Measure measure : measures) {
if (measure != null && measure.getValue() != null) {
hasValue = true;
sum += measure.getValue();
}
}
if (hasValue) {
return sum;
}
return zeroIfNone(zeroIfNone);
}
/**
* Sums a series of measures for the given variation index
*
* @param zeroIfNone whether to return 0 or null in case measures is null
* @param variationIndex the index of the variation to use
* @param measures the series of measures
* @return the sum of the variations for the measure series
*/
public static Double sumOnVariation(boolean zeroIfNone, int variationIndex, Collection<Measure> measures) {
if (measures == null) {
return zeroIfNone(zeroIfNone);
}
Double sum = 0d;
for (Measure measure : measures) {
Double var = measure.getVariation(variationIndex);
if (var != null) {
sum += var;
}
}
return sum;
}
private static Double zeroIfNone(boolean zeroIfNone) {
return zeroIfNone ? 0d : null;
}
}
| joansmith/sonarqube | sonar-plugin-api/src/main/java/org/sonar/api/measures/MeasureUtils.java | Java | lgpl-3.0 | 5,520 | [
30522,
1013,
1008,
1008,
24609,
28940,
4783,
1008,
9385,
1006,
1039,
1007,
2268,
1011,
2355,
24609,
6499,
3126,
3401,
7842,
1008,
5653,
3406,
1024,
3967,
2012,
24609,
6499,
3126,
3401,
11089,
4012,
1008,
1008,
2023,
2565,
2003,
2489,
4007,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
var ajaxManager = (function() {
$jq = jQuery.noConflict();
var requests = [];
return {
addReq: function(opt) {
requests.push(opt);
},
removeReq: function(opt) {
if($jq.inArray(opt, requests) > -1) {
requests.splice($jq.inArray(opt, requests), 1);
}
},
run: function() {
var self = this, orgSuc;
if(requests.length) {
oriSuc = requests[0].complete;
requests[0].complete = function() {
if(typeof oriSuc === 'function') {
oriSuc();
}
requests.shift();
self.run.apply(self, []);
};
$jq.ajax(requests[0]);
} else {
self.tid = setTimeout(function() {
self.run.apply(self, []);
}, 1000);
}
},
stop: function() {
requests = [];
clearTimeout(this.tid);
}
};
}());
ajaxManager.run();
(function($){
$(document).ready(function(){
$('.purAddToCart, .purAddToCartImage').click(function() {
$(this).attr('disabled', 'disabled');
})
$('.Cart66AjaxWarning').hide();
// Added to remove error on double-click when add to cart is clicked
$('.purAddToCart, .purAddToCartImage').click(function() {
$(this).attr('disabled', 'disabled');
})
$('.ajax-button').click(function() {
$(this).attr('disabled', true);
var id = $(this).attr('id').replace('addToCart_', '');
$('#task_' + id).val('ajax');
var product = C66.products[id];
if(C66.trackInventory) {
inventoryCheck(id, C66.ajaxurl, product.ajax, product.name, product.returnUrl, product.addingText);
}
else {
if(product.ajax === 'no') {
$('#task_' + id).val('addToCart');
$('#cartButtonForm_' + id).submit();
return false;
}
else if(product.ajax === 'yes' || product.ajax === 'true') {
buttonTransform(id, C66.ajaxurl, product.name, product.returnUrl, product.addingText);
}
}
return false;
});
$('.modalClose').click(function() {
$('.Cart66Unavailable, .Cart66Warning, .Cart66Error, .alert-message').fadeOut(800);
});
$('#Cart66CancelPayPalSubscription').click(function() {
return confirm('Are you sure you want to cancel your subscription?\n');
});
var original_methods = $('#shipping_method_id').html();
var selected_country = $('#shipping_country_code').val();
$('.methods-country').each(function() {
if(!$(this).hasClass(selected_country) && !$(this).hasClass('all-countries') && !$(this).hasClass('select')) {
$(this).remove();
}
});
$('#shipping_country_code').change(function() {
var selected_country = $(this).val();
$('#shipping_method_id').html(original_methods);
$('.methods-country').each(function() {
if(!$(this).hasClass(selected_country) && !$(this).hasClass('all-countries') && !$(this).hasClass('select')) {
$(this).remove();
}
});
$("#shipping_method_id option:eq(1)").attr('selected','selected').change();
});
$('#shipping_method_id').change(function() {
$('#Cart66CartForm').submit();
});
$('#live_rates').change(function() {
$('#Cart66CartForm').submit();
});
$('.showEntriesLink').click(function() {
var panel = $(this).attr('rel');
$('#' + panel).toggle();
return false;
});
$('#change_shipping_zip_link').click(function() {
$('#set_shipping_zip_row').toggle();
return false;
});
})
})(jQuery);
function getCartButtonFormData(formId) {
$jq = jQuery.noConflict();
var theForm = $jq('#' + formId);
var str = '';
$jq('input:not([type=checkbox], :radio), input[type=checkbox]:checked, input:radio:checked, select, textarea', theForm).each(
function() {
var name = $jq(this).attr('name');
var val = $jq(this).val();
str += name + '=' + encodeURIComponent(val) + '&';
}
);
return str.substring(0, str.length-1);
}
function inventoryCheck(formId, ajaxurl, useAjax, productName, productUrl, addingText) {
$jq = jQuery.noConflict();
var mydata = getCartButtonFormData('cartButtonForm_' + formId);
ajaxManager.addReq({
type: "POST",
url: ajaxurl + '=1',
data: mydata,
dataType: 'json',
success: function(response) {
if(response[0]) {
$jq('#task_' + formId).val('addToCart');
if(useAjax == 'no') {
$jq('#cartButtonForm_' + formId).submit();
}
else {
buttonTransform(formId, ajaxurl, productName, productUrl, addingText);
}
}
else {
$jq('.modalClose').show();
$jq('#stock_message_box_' + formId).fadeIn(300);
$jq('#stock_message_' + formId).html(response[1]);
$jq('#addToCart_' + formId).removeAttr('disabled');
}
},
error: function(xhr,err){
alert("readyState: "+xhr.readyState+"\nstatus: "+xhr.status);
}
});
}
function addToCartAjax(formId, ajaxurl, productName, productUrl, buttonText) {
$jq = jQuery.noConflict();
var options1 = $jq('#cartButtonForm_' + formId + ' .cart66Options.options_1').val();
var options2 = $jq('#cartButtonForm_' + formId + ' .cart66Options.options_2').val();
var itemQuantity = $jq('#Cart66UserQuantityInput_' + formId).val();
var itemUserPrice = $jq('#Cart66UserPriceInput_' + formId).val();
var cleanProductId = formId.split('_');
cleanProductId = cleanProductId[0];
var data = {
cart66ItemId: cleanProductId,
itemName: productName,
options_1: options1,
options_2: options2,
item_quantity: itemQuantity,
item_user_price: itemUserPrice,
product_url: productUrl
};
ajaxManager.addReq({
type: "POST",
url: ajaxurl + '=2',
data: data,
dataType: 'json',
success: function(response) {
$jq('#addToCart_' + formId).removeAttr('disabled');
$jq('#addToCart_' + formId).removeClass('ajaxPurAddToCart');
$jq('#addToCart_' + formId).val(buttonText);
$jq.hookExecute('addToCartAjaxHook', response);
ajaxUpdateCartWidgets(ajaxurl);
if($jq('.customAjaxAddToCartMessage').length > 0) {
$jq('.customAjaxAddToCartMessage').show().html(response.msg);
$jq.hookExecute('customAjaxAddToCartMessage', response);
}
else {
if((response.msgId) == 0){
$jq('.success_' + formId).fadeIn(300);
$jq('.success_message_' + formId).html(response.msg);
if(typeof response.msgHeader !== 'undefined') {
$jq('.success' + formId + ' .message-header').html(response.msgHeader);
}
$jq('.success_' + formId).delay(2000).fadeOut(300);
}
if((response.msgId) == -1){
$jq('.warning_' + formId).fadeIn(300);
$jq('.warning_message_' + formId).html(response.msg);
if(typeof response.msgHeader !== 'undefined') {
$jq('.warning' + formId + ' .message-header').html(response.msgHeader);
}
}
if((response.msgId) == -2){
$jq('.error_' + formId).fadeIn(300);
$jq('.error_message_' + formId).html(response.msg);
if(typeof response.msgHeader !== 'undefined') {
$jq('.error_' + formId + ' .message-header').html(response.msgHeader);
}
}
}
}
})
}
function buttonTransform(formId, ajaxurl, productName, productUrl, addingText) {
$jq = jQuery.noConflict();
var buttonText = $jq('#addToCart_' + formId).val();
$jq('#addToCart_' + formId).attr('disabled', 'disabled');
$jq('#addToCart_' + formId).addClass('ajaxPurAddToCart');
$jq('#addToCart_' + formId).val(addingText);
addToCartAjax(formId, ajaxurl, productName, productUrl, buttonText);
}
function ajaxUpdateCartWidgets(ajaxurl) {
$jq = jQuery.noConflict();
var widgetId = $jq('.Cart66CartWidget').attr('id');
var data = {
action: "ajax_cart_elements"
};
ajaxManager.addReq({
type: "POST",
url: ajaxurl + '=3',
data: data,
dataType: 'json',
success: function(response) {
$jq.hookExecute('cartElementsAjaxHook', response);
$jq('#Cart66AdvancedSidebarAjax, #Cart66WidgetCartContents').show();
$jq('.Cart66WidgetViewCartCheckoutEmpty, #Cart66WidgetCartEmpty').hide();
$jq('#Cart66WidgetCartLink').each(function(){
widgetContent = "<span id=\"Cart66WidgetCartCount\">" + response.summary.count + "</span>";
widgetContent += "<span id=\"Cart66WidgetCartCountText\">" + response.summary.items + "</span>";
widgetContent += "<span id=\"Cart66WidgetCartCountDash\"> – </span>"
widgetContent += "<span id=\"Cart66WidgetCartPrice\">" + response.summary.amount + "</span>";
$jq(this).html(widgetContent).fadeIn('slow');
});
$jq('.Cart66RequireShipping').each(function(){
if(response.shipping == 1) {
$jq(this).show();
}
})
$jq('#Cart66WidgetCartEmptyAdvanced').each(function(){
widgetContent = C66.youHave + ' ' + response.summary.count + " " + response.summary.items + " (" + response.summary.amount + ") " + C66.inYourShoppingCart;
$jq(this).html(widgetContent).fadeIn('slow');
});
$jq("#Cart66AdvancedWidgetCartTable .product_items").remove();
$jq.each(response.products.reverse(), function(index, array){
widgetContent = "<tr class=\"product_items\"><td>";
widgetContent += "<span class=\"Cart66ProductTitle\">" + array.productName + "</span>";
widgetContent += "<span class=\"Cart66QuanPrice\">";
widgetContent += "<span class=\"Cart66ProductQuantity\">" + array.productQuantity + "</span>";
widgetContent += "<span class=\"Cart66MetaSep\"> x </span>";
widgetContent += "<span class=\"Cart66ProductPrice\">" + array.productPrice + "</span>";
widgetContent += "</span>";
widgetContent += "</td><td class=\"Cart66ProductSubtotalColumn\">";
widgetContent += "<span class=\"Cart66ProductSubtotal\">" + array.productSubtotal + "</span>";
widgetContent += "</td></tr>";
$jq("#Cart66AdvancedWidgetCartTable tbody").prepend(widgetContent).fadeIn("slow");
});
$jq('.Cart66Subtotal').each(function(){
$jq(this).html(response.subtotal)
});
$jq('.Cart66Shipping').each(function(){
$jq(this).html(response.shippingAmount)
});
}
})
}
jQuery.extend({
hookExecute: function (function_name, response){
if (typeof window[function_name] == "function"){
window[function_name](response);
return true;
}
else{
return false;
}
}
}); | rbredow/allyzabbacart | js/cart66-library.js | JavaScript | gpl-2.0 | 10,666 | [
30522,
13075,
18176,
24805,
4590,
1027,
1006,
3853,
1006,
1007,
1063,
1002,
1046,
4160,
1027,
1046,
4226,
2854,
1012,
2053,
8663,
29301,
1006,
1007,
1025,
13075,
11186,
1027,
1031,
1033,
1025,
2709,
1063,
5587,
2890,
4160,
1024,
3853,
1006,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
<!DOCTYPE html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta http-equiv="Expires" content="-1">
<meta http-equiv="Pragma" content="no-cache">
<meta http-equiv="Cache-Control" content="no-cache">
<title>105年第十四任總統副總統及第九屆立法委員選舉</title>
<link href="../css/style.css" rel="stylesheet" type="text/css">
<link href="../css/style2.css" rel="stylesheet" type="text/css">
<script type="text/javascript" src="../js/ftiens4.js"></script>
<script type="text/javascript" src="../js/ua.js"></script>
<script type="text/javascript" src="../js/func.js"></script>
<script type="text/javascript" src="../js/treeP1.js"></script>
<script type="text/javascript" src="../js/refresh.js"></script>
</head>
<body id="main-body">
<div id="main-header">
<div id="main-top">
<a class="main-top-logo" href="#">中央選舉委員會</a>
<ul class="main-top-list">
<li class="main-top-item"><a class="main-top-link main-top-link-home" href="../index.html">回首頁</a></li>
<li class="main-top-item"><a class="main-top-link main-top-link-cec" href="http://2016.cec.gov.tw">中選會網站</a></li>
<li class="main-top-item"><a class="main-top-link main-top-link-english" href="../../en/index.html">English</a></li>
</ul>
</div>
</div>
<div id="main-wrap">
<div id="main-banner">
<div class="slideshow">
<img src="../img/main_bg_1.jpg" width="1024" height="300" alt="background" title="background">
</div>
<div class="main-deco"></div>
<div class="main-title"></div>
<a class="main-pvpe main-pvpe-current" href="../IDX/indexP1.html">總統副總統選舉</a>
<a class="main-le" href="../IDX/indexT.html">立法委員選舉</a>
</div>
<div id="main-container">
<div id="main-content">
<table width="1024" border="1" cellpadding="0" cellspacing="0">
<tr>
<td width="180" valign="top">
<div id="divMenu">
<table border="0">
<tr>
<td><a style="text-decoration:none;color:silver" href="http://www.treemenu.net/" target=_blank></a></td>
</tr>
</table>
<span class="TreeviewSpanArea">
<script>initializeDocument()</script>
<noscript>請開啟Javascript功能</noscript>
</span>
</div>
</td>
<td width="796" valign="top">
<div id="divContent">
<!-- 修改區塊 -->
<table width="100%" border="0" cellpadding="0" cellspacing="4">
<tr>
<td><img src="../images/search.png" alt="候選人得票數" title="候選人得票數"> <b>總統副總統選舉 候選人在 新竹縣 新埔鎮得票數 </b></td>
</tr>
<tr valign="bottom">
<td>
<table width="100%" border="0" cellpadding="0" cellspacing="0">
<tr valign="bottom">
<td class="fontNumber"> <img src="../images/nav.gif" alt="候選組數" title="候選組數"> <img src="../images/nav.gif" alt="候選組數" title="候選組數"> 候選組數:3 <img src="../images/nav.gif" alt="應選組數" title="應選組數"> <img src="../images/nav.gif" alt="應選組數" title="應選組數"> 應選組數:1</td>
<td align="right">
<select name="selector_order" class="selectC" tabindex="1" id="orderBy" onChange="changeOrder();">
<option value="n">依號次排序</option>
<option value="s">依得票排序</option>
</select>
</td>
</tr>
</table>
</td>
</tr>
<tr valign="top">
<td>
<table width="100%" border="0" cellpadding="6" cellspacing="1" class="tableT">
<tr class="trHeaderT">
<td>註記</td>
<td>號次</td>
<td><table><tr><td>總統</td><td rowspan=2> 候選人姓名</td></tr><td>副總統</td></table></td>
<td>性別</td>
<td>得票數</td>
<td>得票率%</td>
<td>登記方式</td>
</tr>
<tr class="trT">
<td> </td>
<td>1</td>
<td>朱立倫<br>王如玄</td>
<td>男<br>女</td>
<td class="tdAlignRight">5,991</td>
<td class="tdAlignRight">31.9044</td>
<td>中國國民黨 推薦</td>
</tr>
<tr class="trT">
<td> </td>
<td>2</td>
<td>蔡英文<br>陳建仁</td>
<td>女<br>男</td>
<td class="tdAlignRight">9,047</td>
<td class="tdAlignRight">48.1787</td>
<td>民主進步黨 推薦</td>
</tr>
<tr class="trT">
<td> </td>
<td>3</td>
<td>宋楚瑜<br>徐欣瑩</td>
<td>男<br>女</td>
<td class="tdAlignRight">3,740</td>
<td class="tdAlignRight">19.9169</td>
<td>親民黨 推薦</td>
</tr>
<tr class="trFooterT">
<td colspan="7" align="right">投開票所數 已送/應送: 29/29 </td>
</tr>
</table>
</td>
</tr>
<tr valign="top">
<td>
<table width="100%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="10"></td>
<td valign="top" class="fontNote">
<table>
<tr>
<td>註記說明:</td>
<td align="center">◎</td>
<td>自然當選</td>
</tr>
<tr>
<td></td>
<td align="center">?</td>
<td>同票待抽籤</td>
</tr>
</table>
</td>
<td valign="top" class="fontTimer"><img src="../images/clock2.png" alt="Sat, 16 Jan 2016 22:15:12 +0800" title="Sat, 16 Jan 2016 22:15:12 +0800"> 資料更新時間: 01/16 22:15:07 <br>(網頁每3分鐘自動更新一次)</td>
</tr>
<tr>
<td colspan="3" class="fontNote"></td>
</tr>
</table>
</td>
</tr>
</table>
<!-- 修改區塊 -->
</div>
</td>
</tr>
</table>
</div>
<div class="main-footer"></div>
<div id="divFooter" align=center>[中央選舉委員會] </div>
<!--main-content-->
</div><!--main-container-->
</div><!--END main-wrap-->
<script>setOrder();</script>
<script>setMenuScrollPosY();</script>
</body>
</html>
| gugod/vote-watch-2016 | data/president/n701000300000000/20160116141609/page.html | HTML | cc0-1.0 | 6,577 | [
30522,
1026,
999,
9986,
13874,
16129,
1028,
1026,
2132,
1028,
1026,
18804,
8299,
1011,
1041,
15549,
2615,
1027,
1000,
4180,
1011,
2828,
1000,
4180,
1027,
1000,
3793,
1013,
16129,
1025,
25869,
13462,
1027,
21183,
2546,
1011,
1022,
1000,
1028... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
<?php
class Pager {
/**
* Returns a concatenation of key => value parameters ready to use in a URL.
*/
public static function buildQueryString($dict) {
$params = array();
$str = '';
foreach ($dict as $key => $val) {
$str .= "$key=$val";
$params[] = urlencode($key) . '=' . urlencode($val);
}
return implode('&', $params);
}
/**
* Returns an array with all the information needed to create a pager bar.
* -------------------------------------------------------------------------------------
* | « | ... | c - a | ... | c - 2 | c - 1 | c | c + 1 | c + 2 | ... | c + a | ... | » |
* -------------------------------------------------------------------------------------
* ^
* |
* current page
*
* @param int $rows The total number of rows to show.
* @param int $current The page we want to show, the 'c' in the figure.
* @param string $url The base URL that each item will point to.
* @param int $adjacent Number of items before and after the current page, the 'a' in the figure.
* @param array $params Additional key => value parameters to append to the item's URL.
* @return array $items The information for each item of the pager.
*/
public static function paginate($rows, $current, $url, $adjacent, $params) {
$pages = intval(($rows + PROBLEMS_PER_PAGE - 1) / PROBLEMS_PER_PAGE);
if ($current < 1 || $current > $pages) {
$current = 1;
}
$query = '';
if (count($params) > 0) {
$query = '&' . self::buildQueryString($params);
}
$items = array();
$prev = array('label' => '«', 'url' => '', 'class' => '');
if ($current > 1) {
$prev['url'] = $url . '?page=' . ($current - 1) . $query;
} else {
$prev['url'] = '';
$prev['class'] = 'disabled';
}
array_push($items, $prev);
if ($current > $adjacent + 1) {
$first = array(
'label' => '1',
'url' => $url . '?page=1' . $query,
'class' => ''
);
$period = array(
'label' => '...',
'url' => '',
'class' => 'disabled'
);
array_push($items, $first);
array_push($items, $period);
}
for ($i = max(1, $current - $adjacent); $i <= min($pages, $current + $adjacent); $i++) {
$item = array(
'label' => $i,
'url' => $url . '?page=' . $i . $query,
'class' => ($i == $current) ? 'active' : ''
);
array_push($items, $item);
}
if ($current + $adjacent < $pages) {
$period = array(
'label' => '...',
'url' => '',
'class' => 'disabled'
);
$last = array(
'label' => $pages,
'url' => $url . '?page=' . $pages . $query,
'class' => ''
);
array_push($items, $period);
array_push($items, $last);
}
$next = array('label' => '»', 'url' => '', 'class' => '');
if ($current < $pages) {
$next['url'] = $url . '?page=' . ($current + 1) . $query;
} else {
$next['url'] = '';
$next['class'] = 'disabled';
}
array_push($items, $next);
return $items;
}
}
?>
| rendon/omegaup | frontend/server/libs/Pager.php | PHP | bsd-3-clause | 3,039 | [
30522,
1026,
1029,
25718,
2465,
3931,
2099,
1063,
1013,
1008,
1008,
1008,
5651,
1037,
9530,
16280,
9323,
1997,
3145,
1027,
1028,
3643,
11709,
3201,
2000,
2224,
1999,
1037,
24471,
2140,
1012,
1008,
1013,
2270,
10763,
3853,
3857,
4226,
24769,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
#
# Yet Another UserAgent Analyzer
# Copyright (C) 2013-2022 Niels Basjes
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
ARG TRINO_VERSION
FROM trinodb/trino:${TRINO_VERSION}
ARG YAUAA_VERSION
RUN mkdir -p /usr/lib/trino/plugin/yauaa
COPY ./target/yauaa-trino-${YAUAA_VERSION}-udf.jar /usr/lib/trino/plugin/yauaa
RUN ls -laFR /usr/lib/trino/plugin/yauaa
| nielsbasjes/yauaa | udfs/trino/src/it/docker/Dockerfile | Dockerfile | apache-2.0 | 856 | [
30522,
1001,
1001,
2664,
2178,
5310,
4270,
3372,
17908,
2099,
1001,
9385,
1006,
1039,
1007,
2286,
1011,
16798,
2475,
9152,
9050,
19021,
6460,
2015,
1001,
1001,
7000,
2104,
1996,
15895,
6105,
1010,
2544,
1016,
1012,
1014,
1006,
1996,
1000,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
package com.ekey.service.impl;
import com.ekey.repository.BooksRepository;
import com.ekey.repository.UserRepository;
import com.ekey.models.Book;
import com.ekey.models.Transaction;
import com.ekey.models.User;
import com.ekey.models.out.UserOut;
import com.ekey.service.TransactionService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.Collection;
/**
* Created by faos7 on 12.11.16.
*/
@Service
public class TransactionServiceImpl implements TransactionService {
private static final Logger LOGGER = LoggerFactory.getLogger(TransactionServiceImpl.class);
private UserRepository userRepository;
private BooksRepository booksRepository;
@Autowired
public TransactionServiceImpl(UserRepository userRepository, BooksRepository booksRepository) {
this.userRepository = userRepository;
this.booksRepository = booksRepository;
}
@Override
public Collection<Book> getAllBooksStudentEverHad(Long studentCardId) {
User user = userRepository.findOneByStudentCardId(studentCardId);
Collection<Transaction> transactions = user.getStTransactions();
Collection<Book> res = new ArrayList<>();
for (Transaction tx:transactions) {
res.add(tx.getBook());
}
return res;
}
@Override
public Collection<Book> getAllBooksLibrarianEverGiven(Long studentCardId) {
User user = userRepository.findOneByStudentCardId(studentCardId);
Collection<Transaction> transactions = user.getLbTransactions();
Collection<Book> res = new ArrayList<>();
for (Transaction tx:transactions) {
res.add(tx.getBook());
}
return res;
}
@Override
public Collection<UserOut> getAllBookOwners(String number) {
Book book = booksRepository.findOneByNumber(number).get();
Collection<Transaction> transactions = book.getTransactions();
Collection<UserOut> res = new ArrayList<>();
for (Transaction tx:transactions) {
res.add(new UserOut(tx.getStudent()));
}
return res;
}
@Override
public Transaction getTransactionByBookAndStudent(User student, Book book) {
Collection<Transaction> transactions = student.getStTransactions();
Transaction tx = new Transaction();
for (Transaction transaction:transactions) {
if (tx.isFinished() == false){
if (transaction.getBook() == book){
tx = transaction;
}
}
}
return tx;
}
}
| Faos7/ekey_backend_java | src/main/java/com/ekey/service/impl/TransactionServiceImpl.java | Java | mit | 2,722 | [
30522,
7427,
4012,
1012,
23969,
3240,
1012,
2326,
1012,
17727,
2140,
1025,
12324,
4012,
1012,
23969,
3240,
1012,
22409,
1012,
2808,
2890,
6873,
28307,
2100,
1025,
12324,
4012,
1012,
23969,
3240,
1012,
22409,
1012,
5310,
2890,
6873,
28307,
2... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
/*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.trino.operator.scalar;
import com.google.common.collect.ImmutableList;
import io.trino.jmh.Benchmarks;
import io.trino.metadata.FunctionArgumentDefinition;
import io.trino.metadata.FunctionBinding;
import io.trino.metadata.FunctionListBuilder;
import io.trino.metadata.FunctionMetadata;
import io.trino.metadata.ResolvedFunction;
import io.trino.metadata.Signature;
import io.trino.metadata.SqlScalarFunction;
import io.trino.metadata.TestingFunctionResolution;
import io.trino.operator.DriverYieldSignal;
import io.trino.operator.project.PageProcessor;
import io.trino.spi.Page;
import io.trino.spi.block.Block;
import io.trino.spi.block.BlockBuilder;
import io.trino.spi.type.ArrayType;
import io.trino.spi.type.Type;
import io.trino.spi.type.TypeSignature;
import io.trino.sql.gen.ExpressionCompiler;
import io.trino.sql.relational.CallExpression;
import io.trino.sql.relational.LambdaDefinitionExpression;
import io.trino.sql.relational.RowExpression;
import io.trino.sql.relational.VariableReferenceExpression;
import io.trino.sql.tree.QualifiedName;
import io.trino.type.FunctionType;
import org.openjdk.jmh.annotations.Benchmark;
import org.openjdk.jmh.annotations.BenchmarkMode;
import org.openjdk.jmh.annotations.Fork;
import org.openjdk.jmh.annotations.Measurement;
import org.openjdk.jmh.annotations.Mode;
import org.openjdk.jmh.annotations.OperationsPerInvocation;
import org.openjdk.jmh.annotations.OutputTimeUnit;
import org.openjdk.jmh.annotations.Param;
import org.openjdk.jmh.annotations.Scope;
import org.openjdk.jmh.annotations.Setup;
import org.openjdk.jmh.annotations.State;
import org.openjdk.jmh.annotations.Warmup;
import java.lang.invoke.MethodHandle;
import java.util.List;
import java.util.Optional;
import java.util.concurrent.ThreadLocalRandom;
import java.util.concurrent.TimeUnit;
import static com.google.common.base.Throwables.throwIfUnchecked;
import static com.google.common.base.Verify.verify;
import static io.trino.memory.context.AggregatedMemoryContext.newSimpleAggregatedMemoryContext;
import static io.trino.metadata.FunctionKind.SCALAR;
import static io.trino.metadata.Signature.typeVariable;
import static io.trino.operator.scalar.BenchmarkArrayFilter.ExactArrayFilterFunction.EXACT_ARRAY_FILTER_FUNCTION;
import static io.trino.spi.function.InvocationConvention.InvocationArgumentConvention.NEVER_NULL;
import static io.trino.spi.function.InvocationConvention.InvocationReturnConvention.FAIL_ON_NULL;
import static io.trino.spi.function.OperatorType.LESS_THAN;
import static io.trino.spi.type.BigintType.BIGINT;
import static io.trino.spi.type.BooleanType.BOOLEAN;
import static io.trino.spi.type.TypeSignature.arrayType;
import static io.trino.spi.type.TypeSignature.functionType;
import static io.trino.spi.type.TypeUtils.readNativeValue;
import static io.trino.sql.analyzer.TypeSignatureProvider.fromTypes;
import static io.trino.sql.relational.Expressions.constant;
import static io.trino.sql.relational.Expressions.field;
import static io.trino.testing.TestingConnectorSession.SESSION;
import static io.trino.util.Reflection.methodHandle;
import static java.lang.Boolean.TRUE;
@SuppressWarnings("MethodMayBeStatic")
@State(Scope.Thread)
@OutputTimeUnit(TimeUnit.NANOSECONDS)
@Fork(2)
@Warmup(iterations = 10, time = 500, timeUnit = TimeUnit.MILLISECONDS)
@Measurement(iterations = 10, time = 500, timeUnit = TimeUnit.MILLISECONDS)
@BenchmarkMode(Mode.AverageTime)
public class BenchmarkArrayFilter
{
private static final int POSITIONS = 100_000;
private static final int ARRAY_SIZE = 4;
private static final int NUM_TYPES = 1;
private static final List<Type> TYPES = ImmutableList.of(BIGINT);
static {
verify(NUM_TYPES == TYPES.size());
}
@Benchmark
@OperationsPerInvocation(POSITIONS * ARRAY_SIZE * NUM_TYPES)
public List<Optional<Page>> benchmark(BenchmarkData data)
{
return ImmutableList.copyOf(
data.getPageProcessor().process(
SESSION,
new DriverYieldSignal(),
newSimpleAggregatedMemoryContext().newLocalMemoryContext(PageProcessor.class.getSimpleName()),
data.getPage()));
}
@SuppressWarnings("FieldMayBeFinal")
@State(Scope.Thread)
public static class BenchmarkData
{
@Param({"filter", "exact_filter"})
private String name = "filter";
private Page page;
private PageProcessor pageProcessor;
@Setup
public void setup()
{
TestingFunctionResolution functionResolution = new TestingFunctionResolution()
.addFunctions(new FunctionListBuilder().function(EXACT_ARRAY_FILTER_FUNCTION).getFunctions());
ExpressionCompiler compiler = functionResolution.getExpressionCompiler();
ImmutableList.Builder<RowExpression> projectionsBuilder = ImmutableList.builder();
Block[] blocks = new Block[TYPES.size()];
for (int i = 0; i < TYPES.size(); i++) {
Type elementType = TYPES.get(i);
ArrayType arrayType = new ArrayType(elementType);
ResolvedFunction resolvedFunction = functionResolution.resolveFunction(
QualifiedName.of(name),
fromTypes(arrayType, new FunctionType(ImmutableList.of(BIGINT), BOOLEAN)));
ResolvedFunction lessThan = functionResolution.resolveOperator(LESS_THAN, ImmutableList.of(BIGINT, BIGINT));
projectionsBuilder.add(new CallExpression(resolvedFunction, ImmutableList.of(
field(0, arrayType),
new LambdaDefinitionExpression(
ImmutableList.of(BIGINT),
ImmutableList.of("x"),
new CallExpression(lessThan, ImmutableList.of(constant(0L, BIGINT), new VariableReferenceExpression("x", BIGINT)))))));
blocks[i] = createChannel(POSITIONS, ARRAY_SIZE, arrayType);
}
ImmutableList<RowExpression> projections = projectionsBuilder.build();
pageProcessor = compiler.compilePageProcessor(Optional.empty(), projections).get();
page = new Page(blocks);
}
private static Block createChannel(int positionCount, int arraySize, ArrayType arrayType)
{
BlockBuilder blockBuilder = arrayType.createBlockBuilder(null, positionCount);
for (int position = 0; position < positionCount; position++) {
BlockBuilder entryBuilder = blockBuilder.beginBlockEntry();
for (int i = 0; i < arraySize; i++) {
if (arrayType.getElementType().getJavaType() == long.class) {
arrayType.getElementType().writeLong(entryBuilder, ThreadLocalRandom.current().nextLong());
}
else {
throw new UnsupportedOperationException();
}
}
blockBuilder.closeEntry();
}
return blockBuilder.build();
}
public PageProcessor getPageProcessor()
{
return pageProcessor;
}
public Page getPage()
{
return page;
}
}
public static void main(String[] args)
throws Exception
{
// assure the benchmarks are valid before running
BenchmarkData data = new BenchmarkData();
data.setup();
new BenchmarkArrayFilter().benchmark(data);
Benchmarks.benchmark(BenchmarkArrayFilter.class).run();
}
public static final class ExactArrayFilterFunction
extends SqlScalarFunction
{
public static final ExactArrayFilterFunction EXACT_ARRAY_FILTER_FUNCTION = new ExactArrayFilterFunction();
private static final MethodHandle METHOD_HANDLE = methodHandle(ExactArrayFilterFunction.class, "filter", Type.class, Block.class, MethodHandle.class);
private ExactArrayFilterFunction()
{
super(new FunctionMetadata(
new Signature(
"exact_filter",
ImmutableList.of(typeVariable("T")),
ImmutableList.of(),
arrayType(new TypeSignature("T")),
ImmutableList.of(
arrayType(new TypeSignature("T")),
functionType(new TypeSignature("T"), BOOLEAN.getTypeSignature())),
false),
false,
ImmutableList.of(
new FunctionArgumentDefinition(false),
new FunctionArgumentDefinition(false)),
false,
false,
"return array containing elements that match the given predicate",
SCALAR));
}
@Override
protected ScalarFunctionImplementation specialize(FunctionBinding functionBinding)
{
Type type = functionBinding.getTypeVariable("T");
return new ChoicesScalarFunctionImplementation(
functionBinding,
FAIL_ON_NULL,
ImmutableList.of(NEVER_NULL, NEVER_NULL),
METHOD_HANDLE.bindTo(type));
}
public static Block filter(Type type, Block block, MethodHandle function)
{
int positionCount = block.getPositionCount();
BlockBuilder resultBuilder = type.createBlockBuilder(null, positionCount);
for (int position = 0; position < positionCount; position++) {
Long input = (Long) readNativeValue(type, block, position);
Boolean keep;
try {
keep = (Boolean) function.invokeExact(input);
}
catch (Throwable t) {
throwIfUnchecked(t);
throw new RuntimeException(t);
}
if (TRUE.equals(keep)) {
block.writePositionTo(position, resultBuilder);
}
}
return resultBuilder.build();
}
}
}
| Praveen2112/presto | core/trino-main/src/test/java/io/trino/operator/scalar/BenchmarkArrayFilter.java | Java | apache-2.0 | 10,904 | [
30522,
1013,
1008,
1008,
7000,
2104,
1996,
15895,
6105,
1010,
2544,
1016,
1012,
1014,
1006,
1996,
1000,
6105,
1000,
1007,
1025,
1008,
2017,
2089,
2025,
2224,
2023,
5371,
3272,
1999,
12646,
2007,
1996,
6105,
1012,
1008,
2017,
2089,
6855,
1... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
<?php
class BAInitiativeParser extends RISParser
{
private static $MAX_OFFSET = 5500;
private static $MAX_OFFSET_UPDATE = 200;
public function parse($antrag_id)
{
$antrag_id = IntVal($antrag_id);
if (SITE_CALL_MODE != "cron") echo "- Initiative $antrag_id\n";
if ($antrag_id == 0) {
RISTools::report_ris_parser_error("Fehler BAInitiativeParser", "Initiative-ID 0\n" . print_r(debug_backtrace(), true));
return;
}
$html_details = RISTools::load_file(RIS_BA_BASE_URL . "ba_initiativen_details.jsp?Id=$antrag_id");
$html_dokumente = RISTools::load_file(RIS_BA_BASE_URL . "ba_initiativen_dokumente.jsp?Id=$antrag_id");
//$html_ergebnisse = load_file(RIS_BA_BASE_URL . "/RII/RII/ris_antrag_ergebnisse.jsp?risid=" . $antrag_id);
$daten = new Antrag();
$daten->id = $antrag_id;
$daten->datum_letzte_aenderung = new CDbExpression('NOW()');
$daten->typ = Antrag::$TYP_BA_INITIATIVE;
$dokumente = [];
//$ergebnisse = array();
preg_match("/<h3.*>.* +(.*)<\/h3/siU", $html_details, $matches);
if (count($matches) == 2) $daten->antrags_nr = Antrag::cleanAntragNr($matches[1]);;
$dat_details = explode("<h3 class=\"introheadline\">BA-Initiativen-Nummer", $html_details);
$dat_details = explode("<div class=\"formularcontainer\">", $dat_details[1]);
preg_match_all("/class=\"detail_row\">.*detail_label\">(.*)<\/d.*detail_div\">(.*)<\/div/siU", $dat_details[0], $matches);
$betreff_gefunden = false;
for ($i = 0; $i < count($matches[1]); $i++) switch (trim($matches[1][$i])) {
case "Betreff:":
$betreff_gefunden = true;
$daten->betreff = html_entity_decode($this->text_simple_clean($matches[2][$i]), ENT_COMPAT, "UTF-8");
break;
case "Status:":
$daten->status = $this->text_simple_clean($matches[2][$i]);
break;
case "Bearbeitung:":
$daten->bearbeitung = trim(strip_tags($matches[2][$i]));
break;
}
if (!$betreff_gefunden) {
RISTools::report_ris_parser_error("Fehler BAInitiativeParser", "Kein Betreff\n" . $html_details);
throw new Exception("Betreff nicht gefunden");
}
$dat_details = explode("<div class=\"detailborder\">", $html_details);
$dat_details = explode("<!-- seitenfuss -->", $dat_details[1]);
preg_match_all("/<span class=\"itext\">(.*)<\/span.*detail_div_(left|right|left_long)\">(.*)<\/div/siU", $dat_details[0], $matches);
for ($i = 0; $i < count($matches[1]); $i++) if ($matches[3][$i] != " ") switch ($matches[1][$i]) {
case "Zuständiges Referat:":
$daten->referat = $matches[3][$i];
break;
case "Gestellt am:":
$daten->gestellt_am = $this->date_de2mysql($matches[3][$i]);
break;
case "Wahlperiode:":
$daten->wahlperiode = $matches[3][$i];
break;
case "Bearbeitungsfrist:":
$daten->bearbeitungsfrist = $this->date_de2mysql($matches[3][$i]);
break;
case "Registriert am:":
$daten->registriert_am = $this->date_de2mysql($matches[3][$i]);
break;
case "Bezirksausschuss:":
$daten->ba_nr = IntVal($matches[3][$i]);
break;
case "Typ:":
$daten->antrag_typ = strip_tags($matches[3][$i]);
break;
case "TO aufgenommen am:":
$daten->initiative_to_aufgenommen = $this->date_de2mysql($matches[3][$i]);
break;
}
if ($daten->wahlperiode == "") $daten->wahlperiode = "?";
preg_match_all("/<li><span class=\"iconcontainer\">.*title=\"([^\"]+)\"[^>]+href=\"(.*)\".*>(.*)<\/a>/siU", $html_dokumente, $matches);
for ($i = 0; $i < count($matches[1]); $i++) {
$dokumente[] = [
"url" => $matches[2][$i],
"name" => $matches[3][$i],
"name_title" => $matches[1][$i],
];
}
/*
$dat_ergebnisse = explode("<!-- tabellenkopf -->", $html_ergebnisse);
$dat_ergebnisse = explode("<!-- tabellenfuss -->", $dat_ergebnisse[1]);
preg_match_all("<tr>.*bghell tdborder\"><a.*\">(.*)<\/a>.*
*/
if ($daten->ba_nr == 0) {
echo "BA-Initiative $antrag_id: " . "Keine BA-Angabe";
$GLOBALS["RIS_PARSE_ERROR_LOG"][] = "Keine BA-Angabe (Initiative): $antrag_id";
return;
}
$aenderungen = "";
/** @var Antrag $alter_eintrag */
$alter_eintrag = Antrag::model()->findByPk($antrag_id);
$changed = true;
if ($alter_eintrag) {
$changed = false;
if ($alter_eintrag->betreff != $daten->betreff) $aenderungen .= "Betreff: " . $alter_eintrag->betreff . " => " . $daten->betreff . "\n";
if ($alter_eintrag->bearbeitungsfrist != $daten->bearbeitungsfrist) $aenderungen .= "Bearbeitungsfrist: " . $alter_eintrag->bearbeitungsfrist . " => " . $daten->bearbeitungsfrist . "\n";
if ($alter_eintrag->status != $daten->status) $aenderungen .= "Status: " . $alter_eintrag->status . " => " . $daten->status . "\n";
if ($alter_eintrag->fristverlaengerung != $daten->fristverlaengerung) $aenderungen .= "Fristverlängerung: " . $alter_eintrag->fristverlaengerung . " => " . $daten->fristverlaengerung . "\n";
if ($alter_eintrag->initiative_to_aufgenommen != $daten->initiative_to_aufgenommen) $aenderungen .= "In TO Aufgenommen: " . $alter_eintrag->initiative_to_aufgenommen . " => " . $daten->initiative_to_aufgenommen . "\n";
if ($aenderungen != "") $changed = true;
if ($alter_eintrag->wahlperiode == "") $alter_eintrag->wahlperiode = "?";
}
if ($changed) {
if ($aenderungen == "") $aenderungen = "Neu angelegt\n";
echo "BA-Initiative $antrag_id: Verändert: " . $aenderungen . "\n";
if ($alter_eintrag) {
$alter_eintrag->copyToHistory();
$alter_eintrag->setAttributes($daten->getAttributes());
if (!$alter_eintrag->save()) {
var_dump($alter_eintrag->getErrors());
die("Fehler");
}
$daten = $alter_eintrag;
} else {
if (!$daten->save()) {
var_dump($daten->getErrors());
die("Fehler");
}
}
$daten->resetPersonen();
}
foreach ($dokumente as $dok) {
$aenderungen .= Dokument::create_if_necessary(Dokument::$TYP_BA_INITIATIVE, $daten, $dok);
}
if ($aenderungen != "") {
$aend = new RISAenderung();
$aend->ris_id = $daten->id;
$aend->ba_nr = $daten->ba_nr;
$aend->typ = RISAenderung::$TYP_BA_INITIATIVE;
$aend->datum = new CDbExpression("NOW()");
$aend->aenderungen = $aenderungen;
$aend->save();
/** @var Antrag $antrag */
$antrag = Antrag::model()->findByPk($antrag_id);
$antrag->datum_letzte_aenderung = new CDbExpression('NOW()'); // Auch bei neuen Dokumenten
$antrag->save();
$antrag->rebuildVorgaenge();
}
}
public function parseSeite($seite, $first)
{
if (SITE_CALL_MODE != "cron") echo "BA-Initiativen Seite $seite\n";
$text = RISTools::load_file(RIS_BA_BASE_URL . "ba_initiativen.jsp?Trf=n&Start=$seite");
$txt = explode("<!-- tabellenkopf -->", $text);
$txt = explode("<div class=\"ergebnisfuss\">", $txt[1]);
preg_match_all("/ba_initiativen_details\.jsp\?Id=([0-9]+)[\"'& ]/siU", $txt[0], $matches);
if ($first && count($matches[1]) > 0) RISTools::report_ris_parser_error("BA-Initiativen VOLL", "Erste Seite voll: $seite");
for ($i = count($matches[1]) - 1; $i >= 0; $i--) try {
$this->parse($matches[1][$i]);
} catch (Exception $e) {
echo " EXCEPTION! " . $e . "\n";
}
return $matches[1];
}
public function parseAlle()
{
$anz = static::$MAX_OFFSET;
$first = true;
for ($i = $anz; $i >= 0; $i -= 10) {
if (SITE_CALL_MODE != "cron") echo ($anz - $i) . " / $anz\n";
$this->parseSeite($i, $first);
$first = false;
}
}
public function parseUpdate()
{
echo "Updates: BA-Initiativen\n";
$loaded_ids = [];
$anz = static::$MAX_OFFSET_UPDATE;
for ($i = $anz; $i >= 0; $i -= 10) {
$ids = $this->parseSeite($i, false);
$loaded_ids = array_merge($loaded_ids, array_map("IntVal", $ids));
}
}
public function parseQuickUpdate()
{
}
}
| codeformunich/Muenchen-Transparent | protected/RISParser/BAInitiativeParser.php | PHP | agpl-3.0 | 9,264 | [
30522,
1026,
1029,
25718,
2465,
28477,
29050,
6024,
19362,
8043,
8908,
15544,
27694,
8043,
1063,
2797,
10763,
1002,
4098,
1035,
16396,
1027,
13274,
2692,
1025,
2797,
10763,
1002,
4098,
1035,
16396,
1035,
10651,
1027,
3263,
1025,
2270,
3853,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
<?php
class ModuleController extends Controller{
public function __construct(){
// Pass
}
public function main(){
$this->throwAccessDenied();
}
/**
* Execute command pipeline
*/
public function task(){
ini_set('memory_limit', '512M');
set_time_limit(0);
$this->blank(true);
if($this->request->token != $this->config->cron_token)
$this->throwAccessDenied("Invalid token");
$Tp = new TaskPipeline();
$exe = 0;
while($exe < 5){
if($Tp->executeNext() != true){
break;
}
$exe ++;
}
echo "Executed: $exe";
}
/**
* Send email queue
*/
public function mail(){
set_time_limit(0);
$this->blank(true);
$db = Db::getInstance();
if($this->request->token != $this->config->cron_token)
$this->throwAccessDenied("Invalid token");
$sent = 0;
while($sent < 10){
$mailer = $db->fetch("SELECT * FROM mailer WHERE enviado = 0 ORDER BY id_mailer ASC LIMIT 1");
if($mailer->num_rows <= 0)
break;
$db->query("UPDATE mailer SET enviado = 1, fecha_enviado = now() WHERE id_mailer = " . $mailer->row['id_mailer']);
$Mail = new Mail(array(
'to' => $mailer->row['to'],
'from' => $mailer->row['from'],
'subject' => $mailer->row['title'],
'body' => $mailer->row['body'],
'html' => $mailer->row['html'] == 1 ? true : false,
'alt_body' => $mailer->row['alt_body'],
'reply_to' => $mailer->row['from']
));
$sent++;
usleep(10);
}
echo "Sent: $sent";
}
/**
* Delete temporal files to free up space
*/
public function cleanup(){
$this->blank(true);
if($this->request->token != $this->config->cron_token)
$this->throwAccessDenied("Invalid token");
$files = scandir(PATH_CONTENT.'tmp');
$time = $this->config->tmp_files_lifetime * 60 * 60;
$deleted = 0;
foreach($files as $file){
if($file == "." || $file == "..")
continue;
if(time() - filemtime(PATH_CONTENT.'tmp/'.$file) > $time){
unlink(PATH_CONTENT.'tmp/'.$file);
$deleted++;
}
}
echo "Deleted: $deleted";
}
public function exchange_rates(){
$this->blank(true);
if($this->request->token != $this->config->cron_token)
$this->throwAccessDenied("Invalid token");
$Http = new HttpClient("http://openexchangerates.org/");
$Http->get("/api/latest.json?app_id=". $this->config->ox_app_id);
$response = json_decode($Http->getBody(),true);
$M = new Moneda();
if(!empty($response['rates'])){
foreach($response['rates'] as $key => $rate){
$M->clear();
$M->where("currency_code = '{0}'",$key)->execute();
if($M->rows <= 0){
$M->clear();
$M->populate(array(
'currency_code' => $key,
'rate' => $rate,
'fecha' => 'now()'
))->save();
}else{
$this->db->update("moneda",array(
'rate' => $rate,
'fecha' => 'now()'
),"WHERE currency_code = '".$this->db->escape($key)."'");
}
}
}
}
public function captcha(){
$this->load->extension('cool_captcha');
$captcha = new SimpleCaptcha();
$captcha->resourcesPath = PATH_EXTENSIONS."cool_captcha/resources";
$captcha->wordsFile = 'words/es.php';
$captcha->blur = false;
//$captcha->minWordLength = 3;
$captcha->CreateImage();
die();
}
}
| rgamba/falcode | controller/default/sys/ModuleController.php | PHP | bsd-3-clause | 4,065 | [
30522,
1026,
1029,
25718,
2465,
11336,
8663,
13181,
10820,
8908,
11486,
1063,
2270,
3853,
1035,
1035,
9570,
1006,
1007,
1063,
1013,
1013,
3413,
1065,
2270,
3853,
2364,
1006,
1007,
1063,
1002,
2023,
1011,
1028,
5466,
6305,
9623,
27903,
6340,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
/*
* Copyright (c) 2016 Intel Corporation
*
* SPDX-License-Identifier: Apache-2.0
*/
#ifndef ZEPHYR_INCLUDE_ARCH_NIOS2_ASM_INLINE_GCC_H_
#define ZEPHYR_INCLUDE_ARCH_NIOS2_ASM_INLINE_GCC_H_
#ifdef __cplusplus
extern "C" {
#endif
/*
* The file must not be included directly
* Include arch/cpu.h instead
*/
#ifndef _ASMLANGUAGE
#include <zephyr/types.h>
#include <toolchain.h>
#endif /* _ASMLANGUAGE */
#ifdef __cplusplus
}
#endif
#endif /* _ASM_INLINE_GCC_PUBLIC_GCC_H */
| GiulianoFranchetto/zephyr | include/arch/nios2/asm_inline_gcc.h | C | apache-2.0 | 483 | [
30522,
1013,
1008,
1008,
9385,
1006,
1039,
1007,
2355,
13420,
3840,
1008,
1008,
23772,
2595,
1011,
6105,
1011,
8909,
4765,
18095,
1024,
15895,
1011,
1016,
1012,
1014,
1008,
1013,
1001,
2065,
13629,
2546,
27838,
21281,
2099,
1035,
2421,
1035... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
#!/usr/bin/env python
import os
import sys
if __name__ == "__main__":
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "remakery.settings")
from django.core.management import execute_from_command_line
execute_from_command_line(sys.argv)
| symroe/remakery | manage.py | Python | mit | 251 | [
30522,
1001,
999,
1013,
2149,
2099,
1013,
8026,
1013,
4372,
2615,
18750,
12324,
9808,
12324,
25353,
2015,
2065,
1035,
1035,
2171,
1035,
1035,
1027,
1027,
1000,
1035,
1035,
2364,
1035,
1035,
1000,
1024,
9808,
1012,
4372,
21663,
2239,
1012,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
void ConfigTriggerMakerPP2016(){
gROOT->LoadMacro("$ALICE_PHYSICS/PWG/EMCAL/macros/AddTaskEmcalTriggerMakerNew.C");
AliEmcalTriggerMakerTask *triggermaker = AddTaskEmcalTriggerMakerNew("EmcalTriggers", "", "", kTRUE);
triggermaker->SetUseL0Amplitudes(kFALSE);
triggermaker->SelectCollisionCandidates(AliVEvent::kAny);
//triggermaker->SelectCollisionCandidates(AliVEvent::kAnyINT | AliVEvent::kEMCEGA | AliVEvent::kEMCEJE);
triggermaker->GetTriggerMaker()->ConfigureForPP2015();
}
| mfasDa/pdsftrain | basics/ConfigTriggerMakerPP2016.C | C++ | gpl-3.0 | 486 | [
30522,
11675,
9530,
8873,
13512,
3089,
13327,
8571,
9397,
11387,
16048,
1006,
1007,
1063,
24665,
17206,
1011,
1028,
7170,
22911,
3217,
1006,
1000,
1002,
5650,
1035,
5584,
1013,
1052,
27767,
1013,
7861,
9289,
1013,
26632,
2015,
1013,
5587,
1... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
<div class="woocommerce_gpf_config_{key} woocommerce-gpf-store-default" {displaynone}>
<p>
{defaultinput}
</p>
{prepopulates}
</div>
| Falotico/charm | wp-content/plugins/woocommerce-product-feeds/templates/woo-gpf-field-row-defaults.php | PHP | gpl-2.0 | 138 | [
30522,
1026,
4487,
2615,
2465,
1027,
1000,
15854,
9006,
5017,
3401,
1035,
14246,
2546,
1035,
9530,
8873,
2290,
1035,
1063,
3145,
1065,
15854,
9006,
5017,
3401,
1011,
14246,
2546,
1011,
30524,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("10.TraverseDirectoryXDocument")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("10.TraverseDirectoryXDocument")]
[assembly: AssemblyCopyright("Copyright © 2015")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("0db1c3e2-162a-4e14-b304-0f69cce18d90")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
| emilti/Telerik-Academy-My-Courses | DataBases/03.Processing Xml/Processing XML/10.TraverseDirectoryXDocument/Properties/AssemblyInfo.cs | C# | mit | 1,434 | [
30522,
2478,
2291,
1012,
9185,
1025,
2478,
2291,
1012,
2448,
7292,
1012,
21624,
8043,
7903,
2229,
1025,
2478,
2291,
1012,
2448,
7292,
1012,
6970,
11923,
2121,
7903,
2229,
1025,
1013,
1013,
2236,
2592,
2055,
2019,
3320,
2003,
4758,
2083,
1... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
; lzo1y_s2.asm -- lzo1y_decompress_asm_safe
;
; This file is part of the LZO real-time data compression library.
;
; Copyright (C) 2008 Markus Franz Xaver Johannes Oberhumer
; Copyright (C) 2007 Markus Franz Xaver Johannes Oberhumer
; Copyright (C) 2006 Markus Franz Xaver Johannes Oberhumer
; Copyright (C) 2005 Markus Franz Xaver Johannes Oberhumer
; Copyright (C) 2004 Markus Franz Xaver Johannes Oberhumer
; Copyright (C) 2003 Markus Franz Xaver Johannes Oberhumer
; Copyright (C) 2002 Markus Franz Xaver Johannes Oberhumer
; Copyright (C) 2001 Markus Franz Xaver Johannes Oberhumer
; Copyright (C) 2000 Markus Franz Xaver Johannes Oberhumer
; Copyright (C) 1999 Markus Franz Xaver Johannes Oberhumer
; Copyright (C) 1998 Markus Franz Xaver Johannes Oberhumer
; Copyright (C) 1997 Markus Franz Xaver Johannes Oberhumer
; Copyright (C) 1996 Markus Franz Xaver Johannes Oberhumer
; All Rights Reserved.
;
; The LZO library is free software; you can redistribute it and/or
; modify it under the terms of the GNU General Public License as
; published by the Free Software Foundation; either version 2 of
; the License, or (at your option) any later version.
;
; The LZO library is distributed in the hope that it will be useful,
; but WITHOUT ANY WARRANTY; without even the implied warranty of
; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
; GNU General Public License for more details.
;
; You should have received a copy of the GNU General Public License
; along with the LZO library; see the file COPYING.
; If not, write to the Free Software Foundation, Inc.,
; 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
;
; Markus F.X.J. Oberhumer
; <markus@oberhumer.com>
; http://www.oberhumer.com/opensource/lzo/
;
; /***** DO NOT EDIT - GENERATED AUTOMATICALLY *****/
include asminit.def
public _lzo1y_decompress_asm_safe
_lzo1y_decompress_asm_safe:
db 85,87,86,83,81,82,131,236,12,252,139,116,36,40,139,124
db 36,48,189,3,0,0,0,141,70,253,3,68,36,44,137,68
db 36,4,137,248,139,84,36,52,3,2,137,4,36,49,192,49
db 219,172,60,17,118,87,44,17,60,4,115,92,141,20,7,57
db 20,36,15,130,130,2,0,0,141,20,6,57,84,36,4,15
db 130,110,2,0,0,137,193,235,110,5,255,0,0,0,141,84
db 6,18,57,84,36,4,15,130,87,2,0,0,138,30,70,8
db 219,116,230,141,68,24,18,235,31,141,180,38,0,0,0,0
db 57,116,36,4,15,130,57,2,0,0,138,6,70,60,16,115
db 127,8,192,116,215,131,192,3,141,84,7,0,57,20,36,15
db 130,37,2,0,0,141,84,6,0,57,84,36,4,15,130,16
db 2,0,0,137,193,193,232,2,33,233,139,22,131,198,4,137
db 23,131,199,4,72,117,243,243,164,138,6,70,60,16,115,64
db 141,87,3,57,20,36,15,130,238,1,0,0,193,232,2,138
db 30,141,151,255,251,255,255,141,4,152,70,41,194,59,84,36
db 48,15,130,218,1,0,0,138,2,136,7,138,66,1,136,71
db 1,138,66,2,136,71,2,1,239,233,163,0,0,0,137,246
db 60,64,114,68,137,193,193,232,2,141,87,255,33,232,138,30
db 193,233,4,141,4,152,70,41,194,73,57,232,115,76,233,181
db 0,0,0,5,255,0,0,0,141,86,3,57,84,36,4,15
db 130,126,1,0,0,138,30,70,8,219,116,231,141,76,24,33
db 49,192,235,20,141,116,38,0,60,32,15,130,200,0,0,0
db 131,224,31,116,224,141,72,2,102,139,6,141,87,255,193,232
db 2,131,198,2,41,194,57,232,114,110,59,84,36,48,15,130
db 77,1,0,0,141,4,15,57,4,36,15,130,58,1,0,0
db 137,203,193,235,2,116,17,139,2,131,194,4,137,7,131,199
db 4,75,117,243,33,233,116,9,138,2,66,136,7,71,73,117
db 247,138,70,254,33,232,15,132,196,254,255,255,141,20,7,57
db 20,36,15,130,2,1,0,0,141,20,6,57,84,36,4,15
db 130,238,0,0,0,138,14,70,136,15,71,72,117,247,138,6
db 70,233,42,255,255,255,137,246,59,84,36,48,15,130,223,0
db 0,0,141,68,15,0,57,4,36,15,130,203,0,0,0,135
db 214,243,164,137,214,235,170,129,193,255,0,0,0,141,86,3
db 57,84,36,4,15,130,169,0,0,0,138,30,70,8,219,116
db 230,141,76,11,9,235,21,144,60,16,114,44,137,193,131,224
db 8,193,224,13,131,225,7,116,225,131,193,2,102,139,6,131
db 198,2,141,151,0,192,255,255,193,232,2,116,57,41,194,233
db 38,255,255,255,141,116,38,0,141,87,2,57,20,36,114,106
db 193,232,2,138,30,141,87,255,141,4,152,70,41,194,59,84
db 36,48,114,93,138,2,136,7,138,90,1,136,95,1,131,199
db 2,233,43,255,255,255,131,249,3,15,149,192,59,60,36,119
db 57,139,84,36,40,3,84,36,44,57,214,119,38,114,29,43
db 124,36,48,139,84,36,52,137,58,247,216,131,196,12,90,89
db 91,94,95,93,195,184,1,0,0,0,235,227,184,8,0,0
db 0,235,220,184,4,0,0,0,235,213,184,5,0,0,0,235
db 206,184,6,0,0,0,235,199,144,141,180,38,0,0,0,0
end
| JosefMeixner/opentoonz | thirdparty/lzo/2.03/asm/i386/src_masm/lzo1y_s2.asm | Assembly | bsd-3-clause | 4,388 | [
30522,
1025,
1048,
6844,
2487,
2100,
1035,
1055,
2475,
1012,
2004,
2213,
1011,
1011,
1048,
6844,
2487,
2100,
1035,
21933,
8737,
8303,
1035,
2004,
2213,
1035,
3647,
1025,
1025,
2023,
5371,
2003,
2112,
1997,
1996,
1048,
6844,
2613,
1011,
20... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
/***
*mbsupr.c - Convert string upper case (MBCS)
*
* Copyright (c) 1985-1997, Microsoft Corporation. All rights reserved.
*
*Purpose:
* Convert string upper case (MBCS)
*
*******************************************************************************/
#ifdef _MBCS
#if defined (_WIN32)
#include <awint.h>
#endif /* defined (_WIN32) */
#include <mtdll.h>
#include <cruntime.h>
#include <ctype.h>
#include <mbdata.h>
#include <mbstring.h>
#include <mbctype.h>
/***
* _mbsupr - Convert string upper case (MBCS)
*
*Purpose:
* Converts all the lower case characters in a string
* to upper case in place. Handles MBCS chars correctly.
*
*Entry:
* unsigned char *string = pointer to string
*
*Exit:
* Returns a pointer to the input string; no error return.
*
*Exceptions:
*
*******************************************************************************/
unsigned char * __cdecl _mbsupr(
unsigned char *string
)
{
unsigned char *cp;
_mlock(_MB_CP_LOCK);
for (cp=string; *cp; cp++)
{
if (_ISLEADBYTE(*cp))
{
#if defined (_WIN32)
int retval;
unsigned char ret[4];
if ((retval = __crtLCMapStringA(__mblcid,
LCMAP_UPPERCASE,
cp,
2,
ret,
2,
__mbcodepage,
TRUE)) == 0)
{
_munlock(_MB_CP_LOCK);
return NULL;
}
*cp = ret[0];
if (retval > 1)
*(++cp) = ret[1];
#else /* defined (_WIN32) */
int mbval = ((*cp) << 8) + *(cp+1);
cp++;
if ( mbval >= _MBLOWERLOW1
&& mbval <= _MBLOWERHIGH1 )
*cp -= _MBCASEDIFF1;
else if (mbval >= _MBLOWERLOW2
&& mbval <= _MBLOWERHIGH2 )
*cp -= _MBCASEDIFF2;
#endif /* defined (_WIN32) */
}
else
/* single byte, macro version */
*cp = (unsigned char) _mbbtoupper(*cp);
}
_munlock(_MB_CP_LOCK);
return string ;
}
#endif /* _MBCS */
| hyller/CodeLibrary | The_Standard_C_Library/MBSUPR.C | C++ | unlicense | 2,615 | [
30522,
1013,
1008,
1008,
1008,
1008,
16914,
6342,
18098,
1012,
30524,
27262,
2015,
1007,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
<?php
namespace Renatio\DynamicPDF\Console;
use Illuminate\Console\Command;
use Renatio\DynamicPDF\Models\Layout;
use Renatio\DynamicPDF\Models\Template;
use System\Classes\PluginManager;
use System\Models\Parameter;
class Demo extends Command
{
protected $signature = 'dynamicpdf:demo {--disable}';
protected $description = 'Enable/Disable PDF demo templates.';
public function handle()
{
if ($this->option('disable')) {
$this->disableDemo();
} else {
$this->enableDemo();
}
}
protected function enableDemo()
{
Parameter::set('renatio::dynamicpdf.demo', 1);
$this->info(e(trans('renatio.dynamicpdf::lang.demo.enabled')));
}
protected function disableDemo()
{
$plugin = PluginManager::instance()->findByNamespace('Renatio.DynamicPDF');
foreach ($plugin->registerPDFTemplates() as $template) {
Template::where('code', $template)->delete();
}
foreach ($plugin->registerPDFLayouts() as $layout) {
Layout::where('code', $layout)->delete();
}
Parameter::set('renatio::dynamicpdf.demo', 0);
$this->info(e(trans('renatio.dynamicpdf::lang.demo.disabled')));
}
}
| mplodowski/dynamicpdf-plugin | console/Demo.php | PHP | mit | 1,254 | [
30522,
1026,
1029,
25718,
3415,
15327,
14916,
10450,
2080,
1032,
8790,
17299,
2546,
1032,
10122,
1025,
2224,
5665,
12717,
12556,
1032,
10122,
1032,
3094,
1025,
2224,
14916,
10450,
2080,
1032,
8790,
17299,
2546,
1032,
4275,
1032,
9621,
1025,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
/*
Copyright 2012-2016 Michael Pozhidaev <michael.pozhidaev@gmail.com>
This file is part of LUWRAIN.
LUWRAIN is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public
License as published by the Free Software Foundation; either
version 3 of the License, or (at your option) any later version.
LUWRAIN is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
*/
package org.luwrain.core;
import java.util.*;
class ShortcutManager
{
class Entry
{
String name = "";
Shortcut shortcut;
Entry(String name, Shortcut shortcut)
{
NullCheck.notNull(name, "name");
NullCheck.notNull(shortcut, "shortcut");
if (name.trim().isEmpty())
throw new IllegalArgumentException("name may not be empty");
this.name = name;
this.shortcut = shortcut;
}
}
private final TreeMap<String, Entry> shortcuts = new TreeMap<String, Entry>();
boolean add(Shortcut shortcut)
{
NullCheck.notNull(shortcut, "shortcut");
final String name = shortcut.getName();
if (name == null || name.trim().isEmpty())
return false;
if (shortcuts.containsKey(name))
return false;
shortcuts.put(name, new Entry(name, shortcut));
return true;
}
Application[] prepareApp(String name, String[] args)
{
NullCheck.notNull(name, "name");
NullCheck.notNullItems(args, "args");
if (name.trim().isEmpty())
throw new IllegalArgumentException("name may not be empty");
if (!shortcuts.containsKey(name))
return null;
return shortcuts.get(name).shortcut.prepareApp(args);
}
String[] getShortcutNames()
{
final Vector<String> res = new Vector<String>();
for(Map.Entry<String, Entry> e: shortcuts.entrySet())
res.add(e.getKey());
String[] str = res.toArray(new String[res.size()]);
Arrays.sort(str);
return str;
}
void addBasicShortcuts()
{
add(new Shortcut(){
@Override public String getName()
{
return "registry";
}
@Override public Application[] prepareApp(String[] args)
{
Application[] res = new Application[1];
res[0] = new org.luwrain.app.registry.RegistryApp();
return res;
}
});
}
void addOsShortcuts(Luwrain luwrain, Registry registry)
{
NullCheck.notNull(luwrain, "luwrain");
NullCheck.notNull(registry, "registry");
registry.addDirectory(Settings.OS_SHORTCUTS_PATH);
for(String s: registry.getDirectories(Settings.OS_SHORTCUTS_PATH))
{
if (s.trim().isEmpty())
continue;
final OsCommands.OsShortcut shortcut = new OsCommands.OsShortcut(luwrain);
if (shortcut.init(Settings.createOsShortcut(registry, Registry.join(Settings.OS_SHORTCUTS_PATH, s))))
add(shortcut);
}
}
}
| rPman/luwrain | src/main/java/org/luwrain/core/ShortcutManager.java | Java | gpl-3.0 | 2,884 | [
30522,
1013,
1008,
9385,
2262,
1011,
2355,
2745,
13433,
19436,
6858,
2615,
1026,
2745,
1012,
13433,
19436,
6858,
2615,
1030,
20917,
4014,
1012,
4012,
1028,
2023,
5371,
2003,
2112,
1997,
11320,
13088,
8113,
1012,
11320,
13088,
8113,
2003,
24... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
#PPP-QuestionParsing-ML-standalone
[](https://travis-ci.org/ProjetPP/PPP-QuestionParsing-ML-Standalone)
[](https://scrutinizer-ci.com/g/ProjetPP/PPP-QuestionParsing-ML-standalone/?branch=master)
[](https://scrutinizer-ci.com/g/ProjetPP/PPP-QuestionParsing-ML-standalone/?branch=master)
We provide here a tool to transform an English question into a triple:
(subject, predicate, object)
We emphasis on keywords questions like "Barack Obama birth date?"
You can find some examples of this transformation is the file data/AnnotatedQuestions.txt.
## How to install
Download the git repository:
```
git clone https://github.com/ProjetPP/PPP-QuestionParsing-ML-standalone
cd PPP-NLP-ML-standalone
```
Then, install the script:
python3 setup.py install
Use the `--user` option if you want to install it only for the current user.
## Bootstrap
Short version: run `./bootstrap.sh`
Detailed version:
###Download the look-up table:
```
cd data
wget http://metaoptimize.s3.amazonaws.com/cw-embeddings-ACL2010/embeddings-scaled.EMBEDDING_SIZE=25.txt.gz
gzip -d embeddings-scaled.EMBEDDING_SIZE=25.txt.gz
```
###Generate the data set
The goal of ppp_questionparsing_ml_standalone/Dataset.py is to transform English questions in a vectorized form that is compatible
with our ML model, according to a lookup table.
The english data set of questions is in the file: data/AnnotatedQuestions.txt
Compile the data set with the command:
python3 demo/Dataset.py
###Learn the Python model
python3 demo/Learn.py
##Use the tool in CLI
Execute the command:
python3 demo/Demo.py
Type a question in English, and the program will compute the triple associated to the question.
Example:
birth date Barack Obama?
(Barack Obama, birth date, ?)
##Use the tool with the server
gunicorn ppp_questionparsing_ml_standalone:app -b 127.0.0.1:8080
In a python shell:
import requests, json
requests.post('http://localhost:8080/', data=json.dumps({'id':
'foo', 'language': 'en', 'measures': {}, 'trace': [], 'tree': {'type':
'sentence', 'value': 'What is the birth date of George Washington?'}})).json()
| ProjetPP/PPP-QuestionParsing-ML-Standalone | README.md | Markdown | mit | 2,491 | [
30522,
1001,
4903,
2361,
1011,
3160,
19362,
7741,
1011,
19875,
1011,
26609,
1031,
999,
1031,
3857,
3570,
1033,
1006,
16770,
1024,
1013,
1013,
10001,
1011,
25022,
1012,
8917,
1013,
4013,
15759,
9397,
1013,
4903,
2361,
1011,
3160,
19362,
7741... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
/*
Copyright_License {
Top Hat Soaring Glide Computer - http://www.tophatsoaring.org/
Copyright (C) 2000-2016 The Top Hat Soaring Project
A detailed list of copyright holders can be found in the file "AUTHORS".
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
}
*/
#include "ConditionMonitors.hpp"
#include "ConditionMonitorAATTime.hpp"
#include "ConditionMonitorFinalGlide.hpp"
#include "ConditionMonitorGlideTerrain.hpp"
#include "ConditionMonitorLandableReachable.hpp"
#include "ConditionMonitorSunset.hpp"
#include "ConditionMonitorWind.hpp"
static ConditionMonitorWind cm_wind;
static ConditionMonitorFinalGlide cm_finalglide;
static ConditionMonitorSunset cm_sunset;
static ConditionMonitorAATTime cm_aattime;
static ConditionMonitorGlideTerrain cm_glideterrain;
static ConditionMonitorLandableReachable cm_landablereachable;
void
ConditionMonitorsUpdate(const NMEAInfo &basic, const DerivedInfo &calculated,
const ComputerSettings &settings)
{
cm_wind.Update(basic, calculated, settings);
cm_finalglide.Update(basic, calculated, settings);
cm_sunset.Update(basic, calculated, settings);
cm_aattime.Update(basic, calculated, settings);
cm_glideterrain.Update(basic, calculated, settings);
cm_landablereachable.Update(basic, calculated, settings);
}
| rdunning0823/tophat | src/Computer/ConditionMonitor/ConditionMonitors.cpp | C++ | gpl-2.0 | 1,954 | [
30522,
1013,
1008,
9385,
1035,
6105,
1063,
2327,
6045,
23990,
30524,
2565,
2003,
2489,
4007,
1025,
2017,
2064,
2417,
2923,
3089,
8569,
2618,
2009,
1998,
1013,
2030,
19933,
2009,
2104,
1996,
3408,
1997,
1996,
27004,
2236,
2270,
6105,
2004,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
---
title: "JavaScript spread operator and Redux reducers"
layout: post
---
The JavaScript spread operator (`...`) can help us write more
declarative code for manipulating and copying objects.
## Redux and state mutation
Redux reducers are used to transform the application state from the old
state to a new state in response to an _action_. It's critical that we
don't modify the old state value when creating the new. In other words
reducers are _pure functions_.
As such it's important to make sure that you don't trample on the
previous state when you are processing an action.
Here's an example, suppose you start off with this state:
{
people: {
bob: {
id: 123,
state: 'Happy',
},
alice: {
id: 456,
state: 'Sad'
}
}
}
And want to process this action:
{
action: 'MAKE_HAPPY',
user: 'alice'
}
We can't just do (in a reducer):
const makeHappy = (state, action) => {
state.people[action.user].state = 'Happy';
return state;
};
Because this would alter the original state as well as returning the
'right' answer. Instead we need to create a fresh copy of our state,
modify it and return the modified copy.
## Using `Object.assign` to clone and modify
`Object.assign` allows us to fairly cleanly copy and modify an object.
In order to avoid modifying the original we work from the inside out
starting with a cloned and modified 'person' object then we do the same to
the 'people' collection and finally the top-level state object.
const makeHappy = (state, action) => {
const newUser = Object.assign({}, state.people[action.user], { state: 'Happy' });
const people = Object.assign({}, state.people);
people[action.user] = newUser;
const newState = Object.assign(state, people);
return newState;
};
Note that we didn't have to clone any of the people objects that were
not being modified - it's fine to use the original value in such cases
and cloning the whole state tree could get prohibitively expensive.
Even so it's pretty long-winded so can Object spread make it any better?
## Using Object spread to clone and modify
The object spread operator allows us to do much the same as the
`Object.assign` method but in a less verbose and more declarative way:
const makeHappy = (state, action) => {
const newUser = { ...state.people[action.user], state: 'Happy' };
const people = { ...state.people };
people[action.user] = newUser;
const newState = { ...state, people };
return newState;
};
## Shortcuts and pitfalls
Both `Object.assign` and the spread operator only create a shallow copy
of an object. So for example...
const originalState = { bob: { name: 'Robert' };
const newState = Object.assign({}, originalState);
newState.bob.age = 42;
...mutates the nested object within `originalState`. `Object.assign`
clones `originalState` but because the key `bob` is just a reference to
the original `{ name: 'Robert' }` object, changing *that* object
changes the nested original state - which is exactly what you don't want
to happen in a Redux reducer.
Writing pure functions like Redux can be a little challenging, code can
be a bit verbose. If you find it's also error prone then it might be
time to consider using the Immutable library to guard against unwanted
state mutations in a way that native JavaScript collections cannot do.
| stevehook/stevehook.github.com | _posts/2018-07-24-javascript-spread.md | Markdown | mit | 3,475 | [
30522,
1011,
1011,
1011,
2516,
1024,
1000,
9262,
22483,
3659,
6872,
1998,
2417,
5602,
5547,
2869,
1000,
9621,
1024,
2695,
1011,
1011,
1011,
1996,
9262,
22483,
3659,
6872,
1006,
1036,
1012,
1012,
1012,
1036,
1007,
2064,
2393,
2149,
4339,
2... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
/**
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.camel.component.rest;
import java.util.Map;
import java.util.Set;
import org.apache.camel.Component;
import org.apache.camel.Consumer;
import org.apache.camel.ExchangePattern;
import org.apache.camel.NoFactoryAvailableException;
import org.apache.camel.NoSuchBeanException;
import org.apache.camel.Processor;
import org.apache.camel.Producer;
import org.apache.camel.spi.FactoryFinder;
import org.apache.camel.spi.Metadata;
import org.apache.camel.spi.RestConfiguration;
import org.apache.camel.spi.RestConsumerFactory;
import org.apache.camel.spi.RestProducerFactory;
import org.apache.camel.spi.UriEndpoint;
import org.apache.camel.spi.UriParam;
import org.apache.camel.spi.UriPath;
import org.apache.camel.support.DefaultEndpoint;
import org.apache.camel.util.HostUtils;
import org.apache.camel.util.ObjectHelper;
import static org.apache.camel.support.RestProducerFactoryHelper.setupComponent;
/**
* The rest component is used for either hosting REST services (consumer) or calling external REST services (producer).
*/
@UriEndpoint(firstVersion = "2.14.0", scheme = "rest", title = "REST", syntax = "rest:method:path:uriTemplate", label = "core,rest", lenientProperties = true)
public class RestEndpoint extends DefaultEndpoint {
public static final String[] DEFAULT_REST_CONSUMER_COMPONENTS = new String[]{"coap", "netty-http", "netty4-http", "jetty", "restlet", "servlet", "spark-java", "undertow"};
public static final String[] DEFAULT_REST_PRODUCER_COMPONENTS = new String[]{"http", "http4", "netty4-http", "jetty", "restlet", "undertow"};
public static final String DEFAULT_API_COMPONENT_NAME = "swagger";
public static final String RESOURCE_PATH = "META-INF/services/org/apache/camel/rest/";
@UriPath(label = "common", enums = "get,post,put,delete,patch,head,trace,connect,options") @Metadata(required = true)
private String method;
@UriPath(label = "common") @Metadata(required = true)
private String path;
@UriPath(label = "common")
private String uriTemplate;
@UriParam(label = "common")
private String consumes;
@UriParam(label = "common")
private String produces;
@UriParam(label = "common")
private String componentName;
@UriParam(label = "common")
private String inType;
@UriParam(label = "common")
private String outType;
@UriParam(label = "common")
private String routeId;
@UriParam(label = "consumer")
private String description;
@UriParam(label = "producer")
private String apiDoc;
@UriParam(label = "producer")
private String host;
@UriParam(label = "producer", multiValue = true)
private String queryParameters;
@UriParam(label = "producer", enums = "auto,off,json,xml,json_xml")
private RestConfiguration.RestBindingMode bindingMode;
private Map<String, Object> parameters;
public RestEndpoint(String endpointUri, RestComponent component) {
super(endpointUri, component);
setExchangePattern(ExchangePattern.InOut);
}
@Override
public RestComponent getComponent() {
return (RestComponent) super.getComponent();
}
public String getMethod() {
return method;
}
/**
* HTTP method to use.
*/
public void setMethod(String method) {
this.method = method;
}
public String getPath() {
return path;
}
/**
* The base path
*/
public void setPath(String path) {
this.path = path;
}
public String getUriTemplate() {
return uriTemplate;
}
/**
* The uri template
*/
public void setUriTemplate(String uriTemplate) {
this.uriTemplate = uriTemplate;
}
public String getConsumes() {
return consumes;
}
/**
* Media type such as: 'text/xml', or 'application/json' this REST service accepts.
* By default we accept all kinds of types.
*/
public void setConsumes(String consumes) {
this.consumes = consumes;
}
public String getProduces() {
return produces;
}
/**
* Media type such as: 'text/xml', or 'application/json' this REST service returns.
*/
public void setProduces(String produces) {
this.produces = produces;
}
public String getComponentName() {
return componentName;
}
/**
* The Camel Rest component to use for the REST transport, such as restlet, spark-rest.
* If no component has been explicit configured, then Camel will lookup if there is a Camel component
* that integrates with the Rest DSL, or if a org.apache.camel.spi.RestConsumerFactory is registered in the registry.
* If either one is found, then that is being used.
*/
public void setComponentName(String componentName) {
this.componentName = componentName;
}
public String getInType() {
return inType;
}
/**
* To declare the incoming POJO binding type as a FQN class name
*/
public void setInType(String inType) {
this.inType = inType;
}
public String getOutType() {
return outType;
}
/**
* To declare the outgoing POJO binding type as a FQN class name
*/
public void setOutType(String outType) {
this.outType = outType;
}
public String getRouteId() {
return routeId;
}
/**
* Name of the route this REST services creates
*/
public void setRouteId(String routeId) {
this.routeId = routeId;
}
public String getDescription() {
return description;
}
/**
* Human description to document this REST service
*/
public void setDescription(String description) {
this.description = description;
}
public Map<String, Object> getParameters() {
return parameters;
}
/**
* Additional parameters to configure the consumer of the REST transport for this REST service
*/
public void setParameters(Map<String, Object> parameters) {
this.parameters = parameters;
}
public String getApiDoc() {
return apiDoc;
}
/**
* The swagger api doc resource to use.
* The resource is loaded from classpath by default and must be in JSon format.
*/
public void setApiDoc(String apiDoc) {
this.apiDoc = apiDoc;
}
public String getHost() {
return host;
}
/**
* Host and port of HTTP service to use (override host in swagger schema)
*/
public void setHost(String host) {
this.host = host;
}
public String getQueryParameters() {
return queryParameters;
}
/**
* Query parameters for the HTTP service to call
*/
public void setQueryParameters(String queryParameters) {
this.queryParameters = queryParameters;
}
public RestConfiguration.RestBindingMode getBindingMode() {
return bindingMode;
}
/**
* Configures the binding mode for the producer. If set to anything
* other than 'off' the producer will try to convert the body of
* the incoming message from inType to the json or xml, and the
* response from json or xml to outType.
*/
public void setBindingMode(RestConfiguration.RestBindingMode bindingMode) {
this.bindingMode = bindingMode;
}
public void setBindingMode(String bindingMode) {
this.bindingMode = RestConfiguration.RestBindingMode.valueOf(bindingMode.toLowerCase());
}
@Override
public Producer createProducer() throws Exception {
if (ObjectHelper.isEmpty(host)) {
// hostname must be provided
throw new IllegalArgumentException("Hostname must be configured on either restConfiguration"
+ " or in the rest endpoint uri as a query parameter with name host, eg rest:" + method + ":" + path + "?host=someserver");
}
RestProducerFactory apiDocFactory = null;
RestProducerFactory factory = null;
if (apiDoc != null) {
log.debug("Discovering camel-swagger-java on classpath for using api-doc: {}", apiDoc);
// lookup on classpath using factory finder to automatic find it (just add camel-swagger-java to classpath etc)
try {
FactoryFinder finder = getCamelContext().getFactoryFinder(RESOURCE_PATH);
Object instance = finder.newInstance(DEFAULT_API_COMPONENT_NAME);
if (instance instanceof RestProducerFactory) {
// this factory from camel-swagger-java will facade the http component in use
apiDocFactory = (RestProducerFactory) instance;
}
parameters.put("apiDoc", apiDoc);
} catch (NoFactoryAvailableException e) {
throw new IllegalStateException("Cannot find camel-swagger-java on classpath to use with api-doc: " + apiDoc);
}
}
String cname = getComponentName();
if (cname != null) {
Object comp = getCamelContext().getRegistry().lookupByName(getComponentName());
if (comp instanceof RestProducerFactory) {
factory = (RestProducerFactory) comp;
} else {
comp = setupComponent(getComponentName(), getCamelContext(), (Map<String, Object>) parameters.get("component"));
if (comp instanceof RestProducerFactory) {
factory = (RestProducerFactory) comp;
}
}
if (factory == null) {
if (comp != null) {
throw new IllegalArgumentException("Component " + getComponentName() + " is not a RestProducerFactory");
} else {
throw new NoSuchBeanException(getComponentName(), RestProducerFactory.class.getName());
}
}
cname = getComponentName();
}
// try all components
if (factory == null) {
for (String name : getCamelContext().getComponentNames()) {
Component comp = setupComponent(name, getCamelContext(), (Map<String, Object>) parameters.get("component"));
if (comp instanceof RestProducerFactory) {
factory = (RestProducerFactory) comp;
cname = name;
break;
}
}
}
parameters.put("componentName", cname);
// lookup in registry
if (factory == null) {
Set<RestProducerFactory> factories = getCamelContext().getRegistry().findByType(RestProducerFactory.class);
if (factories != null && factories.size() == 1) {
factory = factories.iterator().next();
}
}
// no explicit factory found then try to see if we can find any of the default rest consumer components
// and there must only be exactly one so we safely can pick this one
if (factory == null) {
RestProducerFactory found = null;
String foundName = null;
for (String name : DEFAULT_REST_PRODUCER_COMPONENTS) {
Object comp = setupComponent(getComponentName(), getCamelContext(), (Map<String, Object>) parameters.get("component"));
if (comp instanceof RestProducerFactory) {
if (found == null) {
found = (RestProducerFactory) comp;
foundName = name;
} else {
throw new IllegalArgumentException("Multiple RestProducerFactory found on classpath. Configure explicit which component to use");
}
}
}
if (found != null) {
log.debug("Auto discovered {} as RestProducerFactory", foundName);
factory = found;
}
}
if (factory != null) {
log.debug("Using RestProducerFactory: {}", factory);
RestConfiguration config = getCamelContext().getRestConfiguration(cname, true);
Producer producer;
if (apiDocFactory != null) {
// wrap the factory using the api doc factory which will use the factory
parameters.put("restProducerFactory", factory);
producer = apiDocFactory.createProducer(getCamelContext(), host, method, path, uriTemplate, queryParameters, consumes, produces, config, parameters);
} else {
producer = factory.createProducer(getCamelContext(), host, method, path, uriTemplate, queryParameters, consumes, produces, config, parameters);
}
RestProducer answer = new RestProducer(this, producer, config);
answer.setOutType(outType);
answer.setType(inType);
answer.setBindingMode(bindingMode);
return answer;
} else {
throw new IllegalStateException("Cannot find RestProducerFactory in Registry or as a Component to use");
}
}
@Override
public Consumer createConsumer(Processor processor) throws Exception {
RestConsumerFactory factory = null;
String cname = null;
if (getComponentName() != null) {
Object comp = getCamelContext().getRegistry().lookupByName(getComponentName());
if (comp instanceof RestConsumerFactory) {
factory = (RestConsumerFactory) comp;
} else {
comp = getCamelContext().getComponent(getComponentName());
if (comp instanceof RestConsumerFactory) {
factory = (RestConsumerFactory) comp;
}
}
if (factory == null) {
if (comp != null) {
throw new IllegalArgumentException("Component " + getComponentName() + " is not a RestConsumerFactory");
} else {
throw new NoSuchBeanException(getComponentName(), RestConsumerFactory.class.getName());
}
}
cname = getComponentName();
}
// try all components
if (factory == null) {
for (String name : getCamelContext().getComponentNames()) {
Component comp = getCamelContext().getComponent(name);
if (comp instanceof RestConsumerFactory) {
factory = (RestConsumerFactory) comp;
cname = name;
break;
}
}
}
// lookup in registry
if (factory == null) {
Set<RestConsumerFactory> factories = getCamelContext().getRegistry().findByType(RestConsumerFactory.class);
if (factories != null && factories.size() == 1) {
factory = factories.iterator().next();
}
}
// no explicit factory found then try to see if we can find any of the default rest consumer components
// and there must only be exactly one so we safely can pick this one
if (factory == null) {
RestConsumerFactory found = null;
String foundName = null;
for (String name : DEFAULT_REST_CONSUMER_COMPONENTS) {
Object comp = getCamelContext().getComponent(name, true);
if (comp instanceof RestConsumerFactory) {
if (found == null) {
found = (RestConsumerFactory) comp;
foundName = name;
} else {
throw new IllegalArgumentException("Multiple RestConsumerFactory found on classpath. Configure explicit which component to use");
}
}
}
if (found != null) {
log.debug("Auto discovered {} as RestConsumerFactory", foundName);
factory = found;
}
}
if (factory != null) {
// if no explicit port/host configured, then use port from rest configuration
String scheme = "http";
String host = "";
int port = 80;
RestConfiguration config = getCamelContext().getRestConfiguration(cname, true);
if (config.getScheme() != null) {
scheme = config.getScheme();
}
if (config.getHost() != null) {
host = config.getHost();
}
int num = config.getPort();
if (num > 0) {
port = num;
}
// if no explicit hostname set then resolve the hostname
if (ObjectHelper.isEmpty(host)) {
if (config.getHostNameResolver() == RestConfiguration.RestHostNameResolver.allLocalIp) {
host = "0.0.0.0";
} else if (config.getHostNameResolver() == RestConfiguration.RestHostNameResolver.localHostName) {
host = HostUtils.getLocalHostName();
} else if (config.getHostNameResolver() == RestConfiguration.RestHostNameResolver.localIp) {
host = HostUtils.getLocalIp();
}
}
// calculate the url to the rest service
String path = getPath();
if (!path.startsWith("/")) {
path = "/" + path;
}
// there may be an optional context path configured to help Camel calculate the correct urls for the REST services
// this may be needed when using camel-servlet where we cannot get the actual context-path or port number of the servlet engine
// during init of the servlet
String contextPath = config.getContextPath();
if (contextPath != null) {
if (!contextPath.startsWith("/")) {
path = "/" + contextPath + path;
} else {
path = contextPath + path;
}
}
String baseUrl = scheme + "://" + host + (port != 80 ? ":" + port : "") + path;
String url = baseUrl;
if (uriTemplate != null) {
// make sure to avoid double slashes
if (uriTemplate.startsWith("/")) {
url = url + uriTemplate;
} else {
url = url + "/" + uriTemplate;
}
}
Consumer consumer = factory.createConsumer(getCamelContext(), processor, getMethod(), getPath(),
getUriTemplate(), getConsumes(), getProduces(), config, getParameters());
configureConsumer(consumer);
// add to rest registry so we can keep track of them, we will remove from the registry when the consumer is removed
// the rest registry will automatic keep track when the consumer is removed,
// and un-register the REST service from the registry
getCamelContext().getRestRegistry().addRestService(consumer, url, baseUrl, getPath(), getUriTemplate(), getMethod(),
getConsumes(), getProduces(), getInType(), getOutType(), getRouteId(), getDescription());
return consumer;
} else {
throw new IllegalStateException("Cannot find RestConsumerFactory in Registry or as a Component to use");
}
}
@Override
public boolean isSingleton() {
return true;
}
@Override
public boolean isLenientProperties() {
return true;
}
}
| punkhorn/camel-upstream | components/camel-rest/src/main/java/org/apache/camel/component/rest/RestEndpoint.java | Java | apache-2.0 | 20,335 | [
30522,
1013,
1008,
1008,
1008,
7000,
2000,
1996,
15895,
4007,
3192,
1006,
2004,
2546,
1007,
2104,
2028,
2030,
2062,
1008,
12130,
6105,
10540,
1012,
2156,
1996,
5060,
5371,
5500,
2007,
1008,
2023,
2147,
2005,
3176,
2592,
4953,
9385,
6095,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
/*price range*/
$('#sl2').slider();
var RGBChange = function() {
$('#RGB').css('background', 'rgb('+r.getValue()+','+g.getValue()+','+b.getValue()+')')
};
/*scroll to top*/
$(document).ready(function(){
$(function () {
$.scrollUp({
scrollName: 'scrollUp', // Element ID
scrollDistance: 300, // Distance from top/bottom before showing element (px)
scrollFrom: 'top', // 'top' or 'bottom'
scrollSpeed: 300, // Speed back to top (ms)
easingType: 'linear', // Scroll to top easing (see http://easings.net/)
animation: 'fade', // Fade, slide, none
animationSpeed: 200, // Animation in speed (ms)
scrollTrigger: false, // Set a custom triggering element. Can be an HTML string or jQuery object
//scrollTarget: false, // Set a custom target element for scrolling to the top
scrollText: '<i class="fa fa-angle-up"></i>', // Text for element, can contain HTML
scrollTitle: false, // Set a custom <a> title if required.
scrollImg: false, // Set true to use image
activeOverlay: false, // Set CSS color to display scrollUp active point, e.g '#00FFFF'
zIndex: 2147483647 // Z-Index for the overlay
});
});
});
// Returns a random integer between min and max
// Using Math.round() will give you a non-uniform distribution!
function getRandomInt(min, max) {
return Math.floor(Math.random() * (max - min + 1)) + min;
}
// Replace url parameter - WishlistItems
function replaceUrlParam(url, paramName, paramValue) {
var pattern = new RegExp('(' + paramName + '=).*?(&|$)')
var newUrl = url
if (url.search(pattern) >= 0) {
newUrl = url.replace(pattern, '$1' + paramValue + '$2');
}
else {
newUrl = newUrl + (newUrl.indexOf('?') > 0 ? '&' : '?') + paramName + '=' + paramValue
}
return newUrl
}
// Scroll back to selected wishlist item
if (window.location.hash != '') {
var target = window.location.hash;
//var $target = $(target);
$('html, body').stop().animate({
//'scrollTop': $target.offset().top
}, 900, 'swing', function () {
window.location.hash = target;
});
} | ReinID/ReinID | Samples/.Net/.Netproperty4u/Property4U/Scripts/main.js | JavaScript | apache-2.0 | 2,179 | [
30522,
1013,
1008,
3976,
2846,
1008,
1013,
1002,
1006,
1005,
1001,
22889,
2475,
1005,
1007,
1012,
7358,
2099,
1006,
1007,
1025,
13075,
1054,
18259,
22305,
2063,
1027,
3853,
1006,
1007,
1063,
1002,
1006,
1005,
1001,
1054,
18259,
1005,
1007,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
module Travis
class Logger
class Format
def initialize(config = {})
(class << self; self; end).class_eval <<-rb
def format(severity, time, progname, message)
#{compile_format(config || {})}
end
rb
end
def call(severity, time, progname, message)
format(severity, time, progname, message)
end
private
def compile_format(config)
format = '"'
format << "\#{time.strftime('#{config[:time_format]}')} " if config[:time_format]
format << '#{severity[0, 1]} '
format << "app[#{ENV['TRAVIS_PROCESS_NAME']}]: " if ENV['TRAVIS_PROCESS_NAME']
format << 'PID=#{Process.pid} ' if config[:process_id]
format << 'TID=#{Thread.current.object_id} ' if config[:thread_id]
format << '#{message}'
format << '"'
end
end
end
end
| final-ci/travis-support | lib/travis/support/logger/format.rb | Ruby | mit | 951 | [
30522,
11336,
10001,
2465,
8833,
4590,
2465,
4289,
13366,
3988,
4697,
1006,
9530,
8873,
2290,
1027,
1063,
1065,
1007,
1006,
2465,
1026,
1026,
2969,
1025,
2969,
1025,
2203,
1007,
1012,
2465,
1035,
9345,
2140,
1026,
1026,
1011,
21144,
13366,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
/*******************************************************************************
Copyright (C) Marvell International Ltd. and its affiliates
This software file (the "File") is owned and distributed by Marvell
International Ltd. and/or its affiliates ("Marvell") under the following
alternative licensing terms. Once you have made an election to distribute the
File under one of the following license alternatives, please (i) delete this
introductory statement regarding license alternatives, (ii) delete the two
license alternatives that you have not elected to use and (iii) preserve the
Marvell copyright notice above.
********************************************************************************
Marvell Commercial License Option
If you received this File from Marvell and you have entered into a commercial
license agreement (a "Commercial License") with Marvell, the File is licensed
to you under the terms of the applicable Commercial License.
********************************************************************************
Marvell GPL License Option
If you received this File from Marvell, you may opt to use, redistribute and/or
modify this File in accordance with the terms and conditions of the General
Public License Version 2, June 1991 (the "GPL License"), a copy of which is
available along with the File in the license.txt file or by writing to the Free
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 or
on the worldwide web at http://www.gnu.org/licenses/gpl.txt.
THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE IMPLIED
WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE ARE EXPRESSLY
DISCLAIMED. The GPL License provides additional details about this warranty
disclaimer.
********************************************************************************
Marvell BSD License Option
If you received this File from Marvell, you may opt to use, redistribute and/or
modify this File under the following licensing terms.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the name of Marvell nor the names of its contributors may be
used to endorse or promote products derived from this software without
specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*******************************************************************************/
#ifndef __INCmvOsAsmh
#define __INCmvOsAsmh
#include "mvCommon.h"
#if defined(MV_MIPS)
#define CPU_FAMILY MIPS
#include "asm.h"
#elif defined (MV_PPC)
#define CPU_FAMILY PPC
#include <config.h>
#include <74xx_7xx.h>
#include <ppc_asm.tmpl>
#include <asm/cache.h>
#include <asm/mmu.h>
#include <ppc_defs.h>
#elif defined (MV_ARM)
#define CPU_FAMILY ARM
#include <config.h>
/* BE/ LE swap for Asm */
#if defined(MV_CPU_LE)
#define htoll(x) x
#define HTOLL(sr,tr)
#elif defined(MV_CPU_BE)
#define htoll(x) ((((x) & 0x00ff) << 24) | \
(((x) & 0xff00) << 8) | \
(((x) >> 8) & 0xff00) | \
(((x) >> 24) & 0x00ff))
#define HTOLL(sr,temp) /*sr = A ,B ,C ,D */\
eor temp, sr, sr, ROR #16 ; /*temp = A^C,B^D,C^A,D^B */\
bic temp, temp, #0xFF0000 ; /*temp = A^C,0 ,C^A,D^B */\
mov sr, sr, ROR #8 ; /*sr = D ,A ,B ,C */\
eor sr, sr, temp, LSR #8 /*sr = D ,C ,B ,A */
#endif
#define MV_REG_READ_ASM(toReg, tmpReg, regAddr) \
ldr tmpReg, =(regAddr) ; \
ldr toReg, [tmpReg] ; \
HTOLL(toReg,tmpReg)
#define MV_REG_WRITE_ASM(fromReg, tmpReg, regAddr) \
HTOLL(fromReg,tmpReg) ; \
ldr tmpReg, =(regAddr) ; \
str fromReg, [tmpReg]
#define MV_DV_REG_READ_ASM(toReg, tmpReg, regOffs) \
ldr tmpReg, =(MV_DFL_REGS + regOffs) ; \
ldr toReg, [tmpReg] ; \
HTOLL(toReg,tmpReg)
#define MV_DV_REG_WRITE_ASM(fromReg, tmpReg, regOffs) \
HTOLL(fromReg,tmpReg) ; \
ldr tmpReg, =(MV_DFL_REGS + regOffs) ; \
str fromReg, [tmpReg]
#define MV_MEM_READ_ASM(toReg, tmpReg, offs) \
ldr tmpReg, =(offs) ; \
ldr toReg, [tmpReg] ; \
HTOLL(toReg,tmpReg)
#define MV_MEM_WRITE_ASM(fromReg, tmpReg, offs) \
HTOLL(fromReg,tmpReg) ; \
ldr tmpReg, =(offs) ; \
str fromReg, [tmpReg]
#else
#error "CPU type not selected"
#endif
#endif /* __INCmvOsAsmh */
| xobs/u-boot-novena-spl | board/marvell/uboot_oss/mvOsAsm.h | C | gpl-2.0 | 5,905 | [
30522,
1013,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
30524,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
10... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
//==================================================================================
// Copyright (c) 2016 , Advanced Micro Devices, Inc. All rights reserved.
//
/// \author AMD Developer Tools Team
/// \file gdDeprecationStatisticsView.cpp
///
//==================================================================================
//------------------------------ gdDeprecationStatisticsView.cpp ------------------------------
// Qt
#include <AMDTApplicationComponents/Include/acQtIncludes.h>
// Infra:
#include <AMDTBaseTools/Include/gtAssert.h>
#include <AMDTBaseTools/Include/gtPtrVector.h>
#include <AMDTAPIClasses/Include/apMonitoredFunctionBreakPoint.h>
#include <AMDTAPIClasses/Include/apFunctionCallStatistics.h>
#include <AMDTAPIClasses/Include/apGLShaderObject.h>
#include <AMDTAPIClasses/Include/apStatistics.h>
#include <AMDTAPIClasses/Include/Events/apEventsHandler.h>
#include <AMDTApplicationComponents/Include/acColours.h>
#include <AMDTApplicationComponents/Include/acIcons.h>
#include <AMDTApiFunctions/Include/gaGRApiFunctions.h>
#include <AMDTApplicationComponents/Include/acFunctions.h>
// AMDTApplicationFramework:
#include <AMDTApplicationFramework/Include/afAppStringConstants.h>
// Local:
#include <AMDTGpuDebuggingComponents/Include/gdCommandIDs.h>
#include <AMDTGpuDebuggingComponents/Include/gdStringConstants.h>
#include <AMDTGpuDebuggingComponents/Include/gdAidFunctions.h>
#include <AMDTGpuDebuggingComponents/Include/gdDeprecationStringConstants.h>
#include <AMDTApplicationFramework/Include/afGlobalVariableChangedEvent.h>
#include <AMDTGpuDebuggingComponents/Include/gdGDebuggerGlobalVariablesManager.h>
#include <AMDTGpuDebuggingComponents/Include/views/gdDeprecationStatisticsView.h>
// Minimal percentages to show each type of warning (note that the number is floating point
// so this is actually the maximum percentage of the tier below:
#define GD_YELLOW_WARNING_MIN_PCT 0
#define GD_ORANGE_WARNING_MIN_PCT 33.33
#define GD_RED_WARNING_MIN_PCT 66.67
// ---------------------------------------------------------------------------
// Name: gdDeprecationStatisticsView::gdDeprecationStatisticsView
// Description: Constructor
// Arguments: wxWindow* pParent - my parent window
// wxWindowID id
// const wxPoint& pos
// const wxSize& size
// long style
// Return Val:
// Author: Sigal Algranaty
// Date: 25/2/2009
// ---------------------------------------------------------------------------
gdDeprecationStatisticsView::gdDeprecationStatisticsView(QWidget* pParent)
: gdStatisticsViewBase(pParent, GD_STATISTICS_VIEW_DEPRECATION_INDEX, GD_STR_StatisticsViewerDeprectionStatisticsShortName),
_totalAmountOfDeprecatedFunctionCalls(0), _totalAmountOfFunctionCallsInFrame(0)
{
// Add breakpoint actions to context menu:
_addBreakpointActions = true;
// Call the base class initialization function:
init();
}
// ---------------------------------------------------------------------------
// Name: gdDeprecationStatisticsView::~gdDeprecationStatisticsView
// Description: Destructor
// Author: Sigal Algranaty
// Date: 25/2/2009
// ---------------------------------------------------------------------------
gdDeprecationStatisticsView::~gdDeprecationStatisticsView()
{
}
// ---------------------------------------------------------------------------
// Name: gdDeprecationStatisticsView::initListCtrlColumns
// Description: Sets the columns widths and titles
// Author: Sigal Algranaty
// Date: 25/2/2009
// ---------------------------------------------------------------------------
void gdDeprecationStatisticsView::initListCtrlColumns()
{
// Create the "Deprecation Statistics View" columns:
_listControlColumnTitles.push_back(GD_STR_DeprecationStatisticsViewerColumn1Title);
_listControlColumnTitles.push_back(GD_STR_DeprecationStatisticsViewerColumn2Title);
_listControlColumnTitles.push_back(GD_STR_DeprecationStatisticsViewerColumn3Title);
_listControlColumnTitles.push_back(GD_STR_DeprecationStatisticsViewerColumn4Title);
_listControlColumnTitles.push_back(GD_STR_DeprecationStatisticsViewerColumn5Title);
_listControlColumnTitles.push_back(GD_STR_DeprecationStatisticsViewerColumn6Title);
// Create the columns titles:
_listControlColumnWidths.push_back(0.20f);
_listControlColumnWidths.push_back(0.25f);
_listControlColumnWidths.push_back(0.10f);
_listControlColumnWidths.push_back(0.10f);
_listControlColumnWidths.push_back(0.14f);
_listControlColumnWidths.push_back(0.14f);
// Make sure that thousand separators are removed:
m_removeThousandSeparatorOnCopy = true;
// Add postfixes to the columns:
m_columnsPostfixes.push_back("");
m_columnsPostfixes.push_back("");
m_columnsPostfixes.push_back("");
m_columnsPostfixes.push_back("");
m_columnsPostfixes.push_back("");
m_columnsPostfixes.push_back("%");
_widestColumnIndex = 5;
_initialSortColumnIndex = 2;
_sortInfo._sortOrder = Qt::DescendingOrder;
}
// ---------------------------------------------------------------------------
// Name: gdDeprecationStatisticsView::updateFunctionCallsStatisticsList
// Description: Update the current statistics into the listCTRL
// Arguments: const apStatistics& currentStatistics
// Return Val: void
// Author: Sigal Algranaty
// Date: 25/2/2009
// ---------------------------------------------------------------------------
bool gdDeprecationStatisticsView::updateFunctionCallsStatisticsList(const apStatistics& currentStatistics)
{
bool retVal = true;
// Delete the items and their user data:
clearAllStatisticsItems();
// Enable the list
setEnabled(true);
// Reset total number of function calls:
_totalAmountOfDeprecatedFunctionCalls = 0;
_totalAmountOfFunctionCallsInFrame = 0;
// Get the number of function calls statistics:
int functionStatisticsAmount = currentStatistics.amountOfFunctionCallsStatistics();
if (functionStatisticsAmount > 0)
{
// Reset column width - since we change it in non analyze mode:
resetColumnsWidth();
// Calculate the total amount of function calls:
for (int i = 0; i < functionStatisticsAmount; i++)
{
const apFunctionCallStatistics* pFunctionCallStatisticsData = NULL;
bool rc = currentStatistics.getFunctionCallStatistics(i, pFunctionCallStatisticsData);
GT_IF_WITH_ASSERT(rc && pFunctionCallStatisticsData != NULL)
{
// Add the function to the total counter:
gtUInt64 amountOfTimesCalled = pFunctionCallStatisticsData->_amountOfTimesCalled;
_totalAmountOfFunctionCallsInFrame += amountOfTimesCalled;
}
}
// Get current execution mode:
bool rc = gaGetDebuggedProcessExecutionMode(_executionMode);
GT_ASSERT(rc);
// Fill the list:
for (int i = 0; i < functionStatisticsAmount; i++)
{
const apFunctionCallStatistics* pFunctionCallStatisticsData = NULL;
bool ret = currentStatistics.getFunctionCallStatistics(i, pFunctionCallStatisticsData);
GT_IF_WITH_ASSERT(ret && pFunctionCallStatisticsData != NULL)
{
// For analyze mode, count all the deprecation status:
if (_executionMode == AP_ANALYZE_MODE)
{
// Iterate the function deprecation statuses, and add if not 0:
for (int j = AP_DEPRECATION_NONE + 1; j < AP_DEPRECATION_STATUS_AMOUNT; j++)
{
int currentDeprecationStatusNumOfCalls = (*pFunctionCallStatisticsData)._amountOfDeprecatedTimesCalled[j];
if (currentDeprecationStatusNumOfCalls > 0)
{
// Add the function to the list:
retVal = retVal && addFunctionToList(*pFunctionCallStatisticsData, (apFunctionDeprecationStatus)j);
}
}
}
else
{
// Get the function id:
const apMonitoredFunctionId functionId = pFunctionCallStatisticsData->_functionId;
// Get the function type:
unsigned int functionType;
bool rc2 = gaGetMonitoredFunctionType(functionId, functionType);
GT_ASSERT(rc2);
// For debug mode, add only the fully deprecated function:
if (functionType & AP_DEPRECATED_FUNC)
{
retVal = retVal && addFunctionToList(*pFunctionCallStatisticsData, AP_DEPRECATION_FULL);
}
}
}
}
if (_activeContextId.isOpenGLContext())
{
// Add GLSL version deprecation:
addGLSLDeprecationItems();
}
// Add the "More..." item to the list:
// NOTICE: Sigal 26/6/2011 When analyze mode is supported, we should remove this comment!
// addMoreItemToList();
// Add the "Total" item to the list:
addTotalItemToList();
// Sort the item in the list control:
sortItems(0, _sortInfo._sortOrder);
}
else
{
addRow(AF_STR_NotAvailableA);
}
return retVal;
}
// ---------------------------------------------------------------------------
// Name: gdDeprecationStatisticsView::addFunctionToList
// Description: Adds function counter statistics item to the list (for function with enumerations)
// Arguments: const apFunctionCallStatistics& functionStatistics - the function statistics object
// apFunctionDeprecationStatus deprecationStatus - the function deprecation status
// Return Val: bool - Success / failure.
// Author: Sigal Algranaty
// Date: 25/2/2009
// ---------------------------------------------------------------------------
bool gdDeprecationStatisticsView::addFunctionToList(const apFunctionCallStatistics& functionStatistics, apFunctionDeprecationStatus deprecationStatus)
{
bool retVal = true;
// Get the function ID:
apMonitoredFunctionId functionId = functionStatistics._functionId;
// Get the function name:
gtString functionName;
retVal = retVal && gaGetMonitoredFunctionName(functionId, functionName);
GT_IF_WITH_ASSERT(retVal)
{
// Get total number of calls:
gtUInt64 totalNumberOfCalls = 0;
if (_executionMode == AP_DEBUGGING_MODE)
{
totalNumberOfCalls = functionStatistics._amountOfTimesCalled;
}
else
{
// Check the number of function call (for this deprecation status):
totalNumberOfCalls = functionStatistics._amountOfDeprecatedTimesCalled[deprecationStatus];
}
// Add this item number of calls to total calls counter:
_totalAmountOfDeprecatedFunctionCalls += totalNumberOfCalls;
gtString totalCallsAmountString;
gtString totalCallsPercentageString;
totalCallsAmountString.appendFormattedString(L"%ld", totalNumberOfCalls);
totalCallsAmountString.addThousandSeperators();
float percentageCalled = 0;
if (_totalAmountOfFunctionCallsInFrame > 0)
{
// Calculate the appearers percentage:
percentageCalled = totalNumberOfCalls;
percentageCalled *= 100;
percentageCalled /= _totalAmountOfFunctionCallsInFrame;
totalCallsPercentageString.appendFormattedString(L"%.2f", percentageCalled);
}
else
{
totalCallsPercentageString.append(AF_STR_NotAvailable);
}
apAPIVersion deprecatedAtVersion = AP_GL_VERSION_NONE;
apAPIVersion removedAtVersion = AP_GL_VERSION_NONE;
if ((_executionMode == AP_DEBUGGING_MODE) || (deprecationStatus == AP_DEPRECATION_FULL))
{
// Get the deprecated at and removed at versions:
gaGetMonitoredFunctionDeprecationVersion(functionId, deprecatedAtVersion, removedAtVersion);
}
else
{
// Get the deprecation version from the deprecation status class:
bool rc = apFunctionDeprecation::getDeprecationAndRemoveVersionsByStatus(deprecationStatus, deprecatedAtVersion, removedAtVersion);
GT_ASSERT(rc);
}
// Build the deprecation versions strings:
gtString deprecatedAtStr;
gtString removedAtStr;
bool rc1 = apAPIVersionToString(deprecatedAtVersion, deprecatedAtStr);
GT_ASSERT(rc1);
bool rc2 = apAPIVersionToString(removedAtVersion, removedAtStr);
GT_ASSERT(rc2);
// Add the deprecation status to the function name:
// (we have items in format of: glTexImage - Deprecated Argument Value
gtString deprecationStatusStr;
bool rc = apFunctionDeprecationStatusToString(deprecationStatus, deprecationStatusStr);
GT_ASSERT(rc);
// Define the item strings:
QStringList rowStrings;
rowStrings << acGTStringToQString(functionName);
rowStrings << acGTStringToQString(deprecationStatusStr);
rowStrings << acGTStringToQString(totalCallsAmountString);
rowStrings << acGTStringToQString(totalCallsPercentageString);
rowStrings << acGTStringToQString(deprecatedAtStr);
rowStrings << acGTStringToQString(removedAtStr);
// Add the item data:
gdStatisticsViewItemData* pItemData = new gdStatisticsViewItemData;
// Fill the item data;
pItemData->_functionName = functionName;
pItemData->_functionId = functionId;
pItemData->_totalAmountOfTimesCalled = totalNumberOfCalls;
pItemData->_percentageOfTimesCalled = percentageCalled;
pItemData->_deprecatedAtVersion = deprecatedAtVersion;
pItemData->_removedAtVersion = removedAtVersion;
pItemData->_deprecationStatus = deprecationStatus;
// Add row to table:
addRow(rowStrings, pItemData, false, Qt::Unchecked, icon(1));
}
return retVal;
}
// ---------------------------------------------------------------------------
// Name: gdDeprecationStatisticsView::addTotalItemToList
// Description: Adds the "Total" item to the list control.
// Author: Sigal Algranaty
// Date: 25/2/2009
// ---------------------------------------------------------------------------
void gdDeprecationStatisticsView::addTotalItemToList()
{
// Get the amount of list items:
int listSize = rowCount();
if (listSize == 0)
{
// Add an item stating that there are not items:
addEmptyListItem();
}
else
{
// Calculate the % of deprecated function calls:
float deprecatedCallsPercentage = ((float)_totalAmountOfDeprecatedFunctionCalls / (float)_totalAmountOfFunctionCallsInFrame) * 100.0f;
// Build displayed strings:
gtASCIIString totalString;
gtASCIIString totalAmountOfFunctionCallsString;
gtASCIIString totalPrecentageString;
totalString.appendFormattedString("Total (%d items)", listSize);
totalAmountOfFunctionCallsString.appendFormattedString("%ld", _totalAmountOfDeprecatedFunctionCalls);
totalAmountOfFunctionCallsString.addThousandSeperators();
totalPrecentageString.appendFormattedString("%.2f", deprecatedCallsPercentage);
QStringList list;
list << totalString.asCharArray();
list << AF_STR_EmptyA;
list << totalAmountOfFunctionCallsString.asCharArray();
list << totalPrecentageString.asCharArray();
list << AF_STR_EmptyA;
list << AF_STR_EmptyA;
addRow(list, NULL, false, Qt::Unchecked, icon(0));
setItemBold(rowCount() - 1);
}
}
// ---------------------------------------------------------------------------
// Name: gdDeprecationStatisticsView::addTotalItemToList
// Description: Adds the "More..." item to the list control in debugging mode.
// Author: Sigal Algranaty
// Date: 17/3/2009
// ---------------------------------------------------------------------------
void gdDeprecationStatisticsView::addMoreItemToList()
{
if (_executionMode != AP_ANALYZE_MODE)
{
// Get the amount of list items:
QStringList list;
// Insert the item (enumerator) into the list:
list << AF_STR_MoreA;
list << GD_STR_StateChangeStatisticsViewerNonAnalyzeModeA;
list << AF_STR_NotAvailableA;
list << AF_STR_NotAvailableA;
list << AF_STR_NotAvailableA;
list << AF_STR_NotAvailableA;
// Get the icon:
QPixmap* pIcon = icon(2);
addRow(list, NULL, false, Qt::Unchecked, pIcon);
}
}
// ---------------------------------------------------------------------------
// Name: gdDeprecationStatisticsView::initializeImageList
// Description: Create and populate the image list for this item
// Author: Sigal Algranaty
// Date: 25/2/2009
// ---------------------------------------------------------------------------
void gdDeprecationStatisticsView::initializeImageList()
{
// Create the icons from the xpm files:
QPixmap* pEmptyIcon = new QPixmap;
acSetIconInPixmap(*pEmptyIcon, AC_ICON_EMPTY);
QPixmap* pYellowWarningIcon = new QPixmap;
acSetIconInPixmap(*pYellowWarningIcon, AC_ICON_WARNING_YELLOW);
QPixmap* pInfoIcon = new QPixmap;
acSetIconInPixmap(*pInfoIcon, AC_ICON_WARNING_INFO);
// Add the icons to the list
_listIconsVec.push_back(pEmptyIcon); // 0
_listIconsVec.push_back(pYellowWarningIcon); // 1
_listIconsVec.push_back(pInfoIcon); // 2
}
// ---------------------------------------------------------------------------
// Name: gdDeprecationStatisticsView::getItemDeprecationVersions
// Description: Given an item index, the function returns the monitored function
// OpenGL deprecation version, and OpenGL remove version
// Arguments: int itemIndex
// apAPIVersion& deprecatedAtVersion
// apAPIVersion& removedAtVersion
// Return Val: bool - Success / failure.
// Author: Sigal Algranaty
// Date: 2/3/2009
// ---------------------------------------------------------------------------
bool gdDeprecationStatisticsView::getItemDeprecationVersions(int itemIndex, apAPIVersion& deprecatedAtVersion, apAPIVersion& removedAtVersion)
{
bool retVal = false;
gdStatisticsViewItemData* pItemData = gdStatisticsViewBase::getItemData(itemIndex);
GT_IF_WITH_ASSERT(pItemData != NULL)
{
deprecatedAtVersion = pItemData->_deprecatedAtVersion;
removedAtVersion = pItemData->_removedAtVersion;
retVal = true;
}
return retVal;
}
// ---------------------------------------------------------------------------
// Name: gdDeprecationStatisticsView::getItemDeprecationStatus
// Description: Return a selected item deprecation status
// Arguments: int itemIndex
// apFunctionDeprecationStatus& functionDeprecationStatus
// Return Val: bool - Success / failure.
// Author: Sigal Algranaty
// Date: 10/3/2009
// ---------------------------------------------------------------------------
bool gdDeprecationStatisticsView::getItemDeprecationStatus(int itemIndex, apFunctionDeprecationStatus& functionDeprecationStatus)
{
bool retVal = false;
gdStatisticsViewItemData* pItemData = gdStatisticsViewBase::getItemData(itemIndex);
GT_IF_WITH_ASSERT(pItemData != NULL)
{
functionDeprecationStatus = pItemData->_deprecationStatus;
retVal = true;
}
return retVal;
}
// ---------------------------------------------------------------------------
// Name: gdDeprecationStatisticsView::getItemFunctionId
// Description: Return a selected item deprecation status
// Arguments: int itemIndex
// int& functionID
// Return Val: bool - Success / failure.
// Author: Sigal Algranaty
// Date: 10/3/2009
// ---------------------------------------------------------------------------
bool gdDeprecationStatisticsView::getItemFunctionId(int itemIndex, int& functionID)
{
bool retVal = false;
// Get the list size:
gdStatisticsViewItemData* pItemData = gdStatisticsViewBase::getItemData(itemIndex);
GT_IF_WITH_ASSERT(pItemData != NULL)
{
functionID = pItemData->_functionId;
retVal = true;
}
return retVal;
}
// ---------------------------------------------------------------------------
// Name: gdDeprecationStatisticsView::addGLSLDeprecationItems
// Description: Go through the shader objects and check their version
// Add deprecation item for a shader object with a deprecated version
// Author: Sigal Algranaty
// Date: 24/3/2009
// ---------------------------------------------------------------------------
void gdDeprecationStatisticsView::addGLSLDeprecationItems()
{
int amountOfShaders = 0;
bool rc = gaGetAmountOfShaderObjects(_activeContextId._contextId, amountOfShaders);
if (rc)
{
// Iterate the shaders
// (check if there is a shader which is not belong to any program):
for (int curShaderId = 0; curShaderId < amountOfShaders; curShaderId++)
{
// Get the current shader name:
GLuint curShaderName = 0;
rc = gaGetShaderObjectName(_activeContextId._contextId, curShaderId, curShaderName);
if (rc)
{
// Get the current shader details:
gtAutoPtr<apGLShaderObject> aptrShaderDetails = NULL;
rc = gaGetShaderObjectDetails(_activeContextId._contextId, curShaderName, aptrShaderDetails);
// Check the shader version deprecation status:
apGLShaderObject* pShaderObject = aptrShaderDetails.pointedObject();
if (rc && (pShaderObject != NULL))
{
// Get the shader version;
apGLSLVersion shaderVersion = pShaderObject->shaderVersion();
if ((shaderVersion == AP_GLSL_VERSION_1_0) || (shaderVersion == AP_GLSL_VERSION_1_1) || (shaderVersion == AP_GLSL_VERSION_1_2))
{
// Add deprecation:
gtString functionName;
functionName.appendFormattedString(GD_STR_DeprecationShaderName, pShaderObject->shaderName());
gtString deprecationStatusStr;
rc = apFunctionDeprecationStatusToString(AP_DEPRECATION_GLSL_VERSION, deprecationStatusStr);
// Get the deprecation version from the deprecation status class:
apAPIVersion deprecatedAtVersion, removedAtVersion;
rc = apFunctionDeprecation::getDeprecationAndRemoveVersionsByStatus(AP_DEPRECATION_GLSL_VERSION, deprecatedAtVersion, removedAtVersion);
GT_ASSERT(rc);
// Build the deprecation versions strings:
gtString deprecatedAtStr;
gtString removedAtStr;
bool rc1 = apAPIVersionToString(deprecatedAtVersion, deprecatedAtStr);
GT_ASSERT(rc1);
bool rc2 = apAPIVersionToString(removedAtVersion, removedAtStr);
GT_ASSERT(rc2);
// Add the item:
QStringList rowStrings;
// Insert the item into the list:
rowStrings << acGTStringToQString(functionName);
rowStrings << acGTStringToQString(deprecationStatusStr);
rowStrings << AF_STR_NotAvailableA;
rowStrings << AF_STR_NotAvailableA;
rowStrings << acGTStringToQString(deprecatedAtStr);
rowStrings << acGTStringToQString(removedAtStr);
// Add the item data:
gdStatisticsViewItemData* pItemData = new gdStatisticsViewItemData;
// Fill the item data;
pItemData->_functionName = functionName;
pItemData->_functionId = ap_glShaderSource;
pItemData->_totalAmountOfTimesCalled = 0;
pItemData->_percentageOfTimesCalled = 0;
pItemData->_deprecatedAtVersion = deprecatedAtVersion;
pItemData->_removedAtVersion = removedAtVersion;
pItemData->_deprecationStatus = AP_DEPRECATION_GLSL_VERSION;
// Add the row:
addRow(rowStrings, pItemData, false, Qt::Unchecked, icon(1));
}
}
}
}
}
}
// -------------------------------------------------------------------------- -
// Name: gdDeprecationStatisticsView::getItemTooltip
// Description: Get an item tooltip
// Arguments: int itemIndex
// Return Val: gtString
// Author: Yuri Rshtunique
// Date: November 10, 2014
// ---------------------------------------------------------------------------
gtString gdDeprecationStatisticsView::getItemTooltip(int itemIndex)
{
gtString retVal;
// Get the item data:
gdStatisticsViewItemData* pItemData = (gdStatisticsViewItemData*)getItemData(itemIndex);
if (pItemData != NULL)
{
// Build the tooltip string:
gtString functionName = pItemData->_functionName;
gtString deprecationStatusStr;
bool rc = apFunctionDeprecationStatusToString(pItemData->_deprecationStatus, deprecationStatusStr);
GT_ASSERT(rc);
retVal.appendFormattedString(L"%ls: %ls", functionName.asCharArray(), deprecationStatusStr.asCharArray());
}
return retVal;
}
| ilangal-amd/CodeXL | CodeXL/Components/GpuDebugging/AMDTGpuDebuggingComponents/views/src/gdDeprecationStatisticsView.cpp | C++ | mit | 26,164 | [
30522,
1013,
1013,
1027,
1027,
1027,
1027,
1027,
1027,
1027,
1027,
1027,
1027,
1027,
1027,
1027,
1027,
1027,
1027,
1027,
1027,
1027,
1027,
1027,
1027,
1027,
1027,
1027,
1027,
1027,
1027,
1027,
1027,
1027,
1027,
1027,
1027,
1027,
1027,
102... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
---
layout: page
title: Land Census Maps + Journalism
subtitle: "University of Maryland: Color By Number Cartography"
category: intermediate
date: 2015-04-20
author: 'Aurelia Moser'
length: 2
---
## Color by Number Cartography w/ CartoDB
Aurelia Moser, Map Scientist, [CartoDB](http://cartodb.com)
Workshop - University of Maryland
**April 20, 2015, 1H30**
Find this document here:
* Stackedit: <http://tinyurl.com/md-cdbwkshop>
* Gist: <http://tinyurl.com/md-cdbgist>
Find the code checkpoints here:
* Github: <https://github.com/auremoser/uofm-2015>

# Outline
0. Visualizing Data
+ Why Maps?
1. Introduction to CartoDB
+ Examples
+ Tour of the interface
+ APIs / JS Libs
2. Mapping **Basics**
+ Setting up accounts!
+ Data import
+ Datasets
3. Mapping **Data**
+ Getting Geospatial Data
+ Data representation in CartoDB (SQL schema)
+ Geocoding + SQL/PostGIS
+ Merging Tables
+ Customizing UI
4. Building a Map
+ Basics of `VisJson` ([ckpt-1](https://github.com/auremoser/uofm-2015/tree/master/ckpt-1-visjson))
+ Quick map with `CreateVis` ([ckpt-2](https://github.com/auremoser/uofm-2015/tree/master/ckpt-2-createVis))
+ Custom map with `CreateLayer` [(ckpt-3](https://github.com/auremoser/uofm-2015/tree/master/ckpt-3-createLayer))
+ Add SQL/CSS Templates ([ckpt-4](https://github.com/auremoser/uofm-2015/tree/master/ckpt-4-sqlcss))
+ Add Buttons ([ckpt-5](https://github.com/auremoser/uofm-2015/tree/master/ckpt-5-buttons))
+ Infowindows ([ckpt-6](https://github.com/auremoser/uofm-2015/tree/master/ckpt-6-info))
+ **BONUS:** Charts ([ckpt-5](https://github.com/auremoser/uofm-2015/tree/master/ckpt-7-chart))
5. Building a Narrative
+ Case Study: [Midwest Downing Map](http://bl.ocks.org/auremoser/f27ed862a4aaf664c31f)
+ Tell Time/Stories: Odyssey + Torque
+ Datatelling: Graphs + Charts ([Census County Chart](http://bl.ocks.org/auremoser/9fe84c3f845ea535e7cc))
6. Wrap-Up and Resources
# Visualizing Data

Source: [The Data Visualization Catalogue](http://www.datavizcatalogue.com/).

Source: [Periodic Table of Visualizations](http://www.visual-literacy.org/periodic_table/periodic_table.html)
####Some terms:
* [**Time-Series**](http://en.wikipedia.org/wiki/Time_series): visualizations that include a temporal component, show change
* [**Thematic Maps**](http://en.wikipedia.org/wiki/Thematic_map): maps related to a body of topics or a subject of discussion
* [**Census Tracts**](http://en.wikipedia.org/wiki/Census_tract): the smallest territorial unit for which population data is available in many countries
####Some software:
* [**CartoDB**](cartodb.com): light open source library and graphical user interface application for hosting and visualizing geospatial data
* [**ChartJS**](http://www.chartjs.org/): light library for creating charts and graphs
####Some resources:
* [Charting Tools Repository](https://github.com/auremoser/chart-tools)
* [Workshops @ CartoDB](http://cartodb.github.io/training/)
* [Recommended tools for Visualizations](http://selection.datavisualization.ch/)
* [Perception Concerns](https://github.com/tmcw/perception)
* [Gestalt Theory](http://emeeks.github.io/gestaltdataviz/section1.html)
* [Color Brewer](http://colorbrewer2.org/) or [Geocolor](http://geocolor.io/)

## Why Maps?

[Map population by relative density](http://projects.aljazeera.com/2013/syrias-refugees/)
* Maps give you more context than most visualizations.
* They allow you to apply data to a recognizable topography.
# Intro to CartoDB
## Examples
+ [Alcatraz Escape Revisited](http://www.washingtonpost.com/news/morning-mix/wp/2014/12/15/the-alcatraz-escapees-could-have-survived-and-this-interactive-model-proves-it/)
+ [LA Sheriff Election Results](http://graphics.latimes.com/2014-la-sheriff-primary-map/)
+ [Starwars Galaxy Map](http://www.swgalaxymap.com/)
+ [Demonstrations in Brazil](http://blog.cartodb.com/mapping-the-world-ongoing-demonstrations-in-brazil/)
+ [Global Forest Watch](http://www.globalforestwatch.org/map/3/15.00/27.00/ALL/grayscale/loss,forestgain?begin=2001-01-01&end=2013-12-31&threshold=30)
+ [Urban Reviewer](http://www.urbanreviewer.org/#map=12/40.7400/-73.9998&sidebar=plans)


## Tour of the interface




## APIs / JS Libs
You can read more about the [CartoDB APIs and JS Library here](http://docs.cartodb.com/cartodb-platform.html)
* [CartoJS](http://docs.cartodb.com/cartodb-platform/cartodb-js.html) - JS library for interacting with CartoDB
* [Maps API](http://docs.cartodb.com/cartodb-platform/maps-api.html) - generate public/private maps with data hosted on your CDB account
* [SQL API](http://docs.cartodb.com/cartodb-platform/sql-api.html) - run sql in your code that dynamically filters/affects/queries your mapped data stored in CartoDB
* [Import API](http://docs.cartodb.com/cartodb-platform/import-api.html) - CRUD files in your CartoDB Account
# Mapping Basics
## Setting Up Accounts
You can setup a _free_ student account today since we're all learning: <https://cartodb.com/signup?plan=academy>

IRE members are eligible for a free upgraded account that includes:
* more space
* private tables ([a Magellan account feature](http://cartodb.com/pricing))
* sync tables
Email cartodb@ire.org with your request for an upgraded account and membership ID, and we'll set you up.
## Data Import
We're going to be building a visualization of land census data in the domestic U.S.

We'll be mapping land tracts according to census information (c. 2014), exploring some choropleth methods and some SQL for manipulating data.

**Census Tracts** are subdivisions of land in the USA, the primary purpose of which is to provide a stable set of geographic units for the presentation of statistical data.

* generally have a population size between 1,200 and 8,000 people, with an optimum size of 4,000 people
* usually covers a contiguous area; however, varies on density of settlement
* sometimes split due to population growth or merged as a result of substantial population decline.

## Datasets
You can fork the dataset we'll be working with, and the files for the workshop here.
Description | Source | Download
---------- | -------- | --------
2014 Census Tracts | [Census.gov](https://www.census.gov/geo/maps-data/data/tiger-line.html) | [tl_2014_us_tract.zip](ftp://ftp2.census.gov/geo/tiger/TIGER2014/TRACT/)
FIPS Tracts Lookup Table | [US Census Bureau](https://www.census.gov/geo/reference/codes/cou.html) | [US_FIPS_Codes.xls](www.schooldata.com/pdfs/US_FIPS_Codes.xls)
2014 County Info | [Census.gov](https://www.census.gov/geo/maps-data/data/tiger-line.html) | [tl_2014_county.zip](ftp://ftp2.census.gov/geo/tiger/TIGER2014/COUNTY/)
** You can also import the data from our "Data Library," all our queries and customizations can be done on the trimmed down library version.

Select **US Census Tracts** and pull it into you dashboard for manipulation.
# Mapping Data
## Getting Geospatial Data
**Geospatial data** is info that ids a geolocation and its characteristic features/frontiers, typically represented by points, lines, polygons, and/or complex geographic features.
### Issues:
+ Comes in multiple formats ([supported formats for CartoDB](http://docs.cartodb.com/cartodb-editor.html#supported-file-formats))
+ Sources uncertain
+ Contains errors
+ etc.
Downloading the Census Data/FIPS directly requires some finessing.
### Data Check:
* check the source and update date of your data
* remove headers/extra columns (in Excel or Open Refine)
* import the csv/xls/geojson and auto-geocoding via carto
* correct column names to more intelligible terms
* correct datatypes
* do any preliminary sql or filtering that suits

Here is what it might look like when you upload your data:

## Data representation in CartoDB (SQL schema)
The most basic SQL statement is:
{% highlight sql %}
SELECT * FROM table_name
{% endhighlight %}
The * means everything. This means that all rows and columns from the table are given back once the query is run.
A more detailed query is like this:
{% highlight sql %}
SELECT
name,
height,
age
FROM
class_list
WHERE
name = 'Aure'
AND (
height > 1.2
OR
height < 1.9
)
{% endhighlight %}
1. `SELECT` is what you're requesting (required)
2. `FROM` is where the data is located (required)
3. `WHERE` is the filter on the data you're requesting (optional)
4. `GROUP BY` and `ORDER BY` are optional additions, you can read more about aggregate/other functions below.
## Geocoding + SQL/PostGIS
There are two special columns in CartoDB:
1. `the_geom`
2. `the_geom_webmercator`
The first of these is in the units of standard latitude/longitude, while the second is a projection based on the [original Mercator projection](http://en.wikipedia.org/wiki/Mercator_projection) but [optimized for the web](http://en.wikipedia.org/wiki/Web_Mercator).
If you want to run SQL commands and see your map update, make sure to `SELECT` the `the_geom_webmercator` because this is the column that's used for mapping--the other is more of a convenience column since most datasets use lat/long.
This is a SQL statement and you can load it in your visualization tray as a way of querying and exploring your data with immediate visual output. In this case, we are calculating the % of water from your "awater" column that occupies each tract using `ST_Area`, and naming a column for that calculation * 100 to make the number less tiny; more appreciable.
{% highlight sql %}
SELECT *, 100 * awater / ST_Area(the_geom::geography) perc_water FROM tl_2014_census_tracts
{% endhighlight %}
This is a query that adds some more information from the sample, to include percent counts for land as well as a total addition to ensure that the data isn't too skewed (everything adds up to 100%).

You can enter queries, apply them, click on "create table from query" in the green field below the column names.
## Customizing UI
You have myriad customization options in the in-browser editor.
* `sql` - run sql and postgis functions across your data
* `wizard` - adjust the type, colors and fills in your map
* `infowindow` - create hovers, tooltips with information from your datatables
* `css` - customize the css and style of your map outside the wizard
* `legends` - create keys for your map
* `filters` - filter the data without sql
### Filters & SQL

Filters are a great way to explore your data. Besides filtering your data, they allow you to see histograms of the distributions, the number of unique entries, or a search box for columns that have a large number of text entries.
### CartoDB Wizard

The Wizard allows you to select your visualization "type" and customize color palettes, design details, and otherwise set the tone for your map.
## Types of visualizations
+ **Simple** -- most basic visualization
+ **Cluster** -- counts number of points within a certain binned region
+ **Choropleth** -- makes a histogram of your data and gives bins different colors depending on the color ramp chosen
+ **Category** -- color data based on unique category (works best for a handful of unique types)
+ **Bubble** -- size markers based on column values
+ **Intensity** -- colors by density
+ **Density** -- data aggregated by number of points within a hexagon
+ **Torque** -- temporal visualization of data
+ **Heat** -- more fluid map of concentration; ephasis on far over near-view

Check out [visualization documentation](http://docs.cartodb.com/cartodb-editor.html#wizards) for more.
###_Simple_ Map
The visualization style _simple_ is the default visualization for all maps.

Styles available in the wizard

* **Marker Fill:** change the size, color, and opacity of all markers
* **Marker Stroke:** change the width, color, and opacity of every marker's border
* **Composite Operation:** change the color of markers when they overlap
* **Label Text:** Text appearing by a marker (can be from columns)
#### Infowindows/hovers

+ Select which column data appear in infowindow by toggling column on
+ Customize further by selecting HTML-view
#### Change basemap
Select basemaps from different providers, use custom color, NASA data, MapBox tiles, etc.

### Choropleth
Choropleth maps show map elements colored according to where a value associated with the map element falls in a range. It's like a histogram where each bin is colored differently according to a color scale you pick. Notice the CartoCSS screenshot above.
**_Quantification_** is an option to pay attention to since it controls how the data is binned into different colors.
* **_Equal interval_** gives bins of equal size across the range, which means that outliers stand out.

* **_Quantile_** bins so that each quantile has approximately the same number of values. This is the default and works for most "normal" data.

* **_Jenks_** aims to increase the standard deviation between each group of data while decreasing the standard deviation within each group. In other words, it increases the similarity within a given group in conjunction with the differences from each of the other groups. The Jenks method does this by shuffling data across each group until it detects an optimization.

* **_Heads/Tails_** breaks can be powerful for data with a long-tail distribution.

Play around with them and see what works best for your dataset.
### CartoCSS basics
[CartoCSS](https://github.com/mapbox/carto/blob/master/docs/latest.md) is the styling language for our maps.

### Legends
...can be easily customized!

You have the option of giving it a title, and changing the text for the colors. You can also change the colors manually, or, even better, change the color ramp back in the wizard.
### Navigation
Click on the 90-degree arrow to get back to view your tables/visualizations



## Merging Tables
Joining and merging tables to make one dataset is a common need. Say you have two datasets related to the same place/map and need to combine them so that they can share the same geometry.
You can do this in SQL [read more here](http://docs.cartodb.com/tutorials/merging_data.html), but CartoDB also has an in-editor button for that.

Here is a usecase relative to these datasets:
* when you the census tract data from the "Data Library", it has county FIPS codes but no placenames
* [this dataset](https://www.dropbox.com/s/eyq2p1uzg2njifx/ga-counties.kml?dl=0) has placenames and FIPS codes for counties, but no geo spatial data to give it a polygon
* you can load them both into cartodb, and select the "merge tables" button
* select `column` or `spatial` join

* select the columns that you want to join on, in this case, both datasets share a "FIPS" column

* toggle the columns you want to exist in your new "joined" dataset

# Building a Map
Once you load your data, you can play with the editor options to see what type of visualization you might light to make.
I started with adding a column called `a–lw` and estimating a value for the amoung of water over land.

Then I thought I should refine this, to check that the aland and awater values represented half of the land distribution for each tract.

## Quick map with `CreateVis`
#### Here's a reference point for this section: [ckpt-1](https://github.com/auremoser/uofm-2015/tree/master/ckpt-1-visjson)
You will need:
+ dataset from above
+ visjson from your account, you can [reference mine](https://github.com/auremoser/uofm-2015/tree/master/ckpt-1-visjson/vis.json) to find yours too.
+ Basic Text Editor
+ Browser
#### Running Locally
* You can open HTML files on your hard drive from a browser. Use CMD+O or CTRL+O like you'd do to open a file in any program.
* You can also run a little server by navigating to the folder where you will store your files and running `http-server &`; you have node installed with http-server setup on most macs! if not, no stress, just follow along.
###VisJson

The viz.json file is the main source of data for CartoDB JavaScript functions (createVis and createLayer) for creating visualizations in the browser.

* Structure of file: JSON
* Defines how to access data: listing servers, subdomains, etc.
* Most important for developers is the `layers` array because it explicitly shows the structure of how visualizations are put together
* Defines base maps, if applicable, as `layers[0]`
* CartoDB data layer is `layers[1]`, may consist of multiple sublayers
* Defines infowindows, which we'll cover in this workshop
* Defines data accessed by using a SQL statement
* Defines styling for tile layers, if applicable
* Defines interactivity (what data shows up on layer events)
* `layer_name` is the also the name of table where data comes from in the account with key `user_name`
You can view it by opening a text editor and loading the file, or downloading a JSON viewer extension for inbrowser views ([Chrome](https://chrome.google.com/webstore/detail/jsonview/chklaanhfefbnpoihckbnefhakgolnmc?hl=en) or [Firefox](https://addons.mozilla.org/en-us/firefox/addon/jsonview/)).
### Creating Basic Visualization in JavaScript
Copy & paste template from [here](https://gist.github.com/auremoser/a57654e18ce06ab396d6).
Overview of template:
1. Included JavaScript libraries and CSS file
2. `map` element
3. `<script>` tags
Create basic visualization using `createVis` by copying and pasting the following either between script tags in your html or by making a file called `[?].js` (I used `main.js` in the template) and referencing it between your script tags:
{% highlight js %}
window.onload = function() {
var vizjson_url = ''; // <-- Paste viz.json URL between quotes
cartodb.createVis(map_id, vizjson_url) // <-- Change map_id to 'map'
.done(function(vis, layers) {
// do stuff
console.log("Map successfully created");
})
.error(function(err) {
// report error
console.log("An error occurred: " + err);
});
}
{% endhighlight %}
`createVis` is excellent for creating maps quickly with very little code. There is a lot of customization with it as well. The documentation is [here](http://docs.cartodb.com/cartodb-platform/cartodb-js.html#visualization).
**Edit the fields to match your map reload your browser window, your map should work.**
## Custom map with `CreateLayer`
#### Here's a reference point for this section: [ckpt-2](https://github.com/auremoser/uofm-2015/tree/master/ckpt-2-createVis)

`createLayer` is the other main method for bring maps to your browser.
The following is the basic createLayer structure (depends on [Leaflet.js](http://leafletjs.com/)):
{% highlight js %}
window.onload = function () {
//
var vizjson_url = 'https://team.cartodb.com/u/aureliamoser/api/v2/viz/c03a644e-e45a-11e4-9d34-0e0c41326911/viz.json'; // <-- Paste viz.json URL between quotes
var options = {
sql: "SELECT * FROM tl_2014_census_tracts",
// cartocss: ""
}
var sublayers = [];
// instantiate map object from Leaflet
var mapObj = new L.Map(map, { // <-- Replace map_id with your #id for rendering
center: [41.8369, -87.6847], // Chicago, IL
zoom: 7 // zoom projection to adjust starting point zoom
});
// add basemap tiles
L.tileLayer('http://{s}.basemaps.cartocdn.com/light_nolabels/{z}/{x}/{y}.png', {
attribution: '© <a href="http://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors'
}).addTo(mapObj);
// add data tile layers here (if you have multiple layers, you can manipulate them in js here)
cartodb.createLayer(mapObj,vizjson_url)
.addTo(mapObj)
.done(function(layer) {
console.log("Map successfully created.");
sublayers[0] = layer.getSubLayer(0);
sublayers[1] = layer.getSubLayer(1);
sublayers[1].set(options); // altering the SQL and CartoCSS; see above
sublayers[1].hide(); // hiding the traffic data
})
.error(function(err) {
console.log("Map not created: " + err);
});
}
{% endhighlight %}
One big difference here is that we explicitly expose the SQL and CartoCSS, allowing for easy customization.

**Edit the fields to match your map reload your browser window, your map should work.**
## Add SQL/CSS Templates
#### Here's a reference point for this section: [ckpt-3](https://github.com/auremoser/uofm-2015/tree/master/ckpt-3-createLayer)
**New goal:** We'll create an interactive map that allows us to toggle between the basic of census tracts and the view of water density in thos tracks.
To accomplish this, we'll crib from the SQL we worked on before.
You can do this a number of ways, we'll be using SQL, you can read documentation on available function magic in the [PostGIS docs](http://postgis.net/docs/) and otherwise just follow along.
Going back to the `createLayer` example we just made:
* Copy the following SQL into your index.html file below the `<style>` tags.
{% highlight sql %}
<script type='sql/text' id='sql'>
SELECT *, 100 * awater / ST_Area(the_geom::geography) perc_water
FROM tl_2014_census_tracts
</script>
{% endhighlight %}
* Paste the following CartoCSS structure in the `<head>` section of your webpage.
* This is a pre-configured Choropleth style. You could also create one on the fly by calculating the range in data and creating bins within that range.
{% highlight css %}
<style type='cartocss/text' id='choropleth'>
/** choropleth visualization */
#tl_2014_census_tracts{
polygon-fill: #FFFFCC;
polygon-opacity: 0.8;
line-color: #FFF;
line-width: 0;
line-opacity: 1;
}
#tl_2014_census_tracts [ perc_water <= 100.829766103904] {
polygon-fill: #253494;
}
#tl_2014_census_tracts [ perc_water <= 6.89127773835036] {
polygon-fill: #2C7FB8;
}
#tl_2014_census_tracts [ perc_water <= 1.99990433083773] {
polygon-fill: #41B6C4;
}
#tl_2014_census_tracts [ perc_water <= 0.782021558262898] {
polygon-fill: #A1DAB4;
}
#tl_2014_census_tracts [ perc_water <= 0.258319771503945] {
polygon-fill: #FFFFCC;
}
</style>
{% endhighlight %}
* Next replace the string for `sql in the options object with
{% highlight js %}
$("#sql").text(),
{% endhighlight %}
(don't forget the comma!), and the string after `cartocss` with
{% highlight js %}
$("#choropleth").text()
{% endhighlight %}
These two pieces of code are just a jQuery operation that finds the HTML element that has an `id` of `sql` or `cartocss` and extracts the text contained within it.
* add a sublayer reference to your data tile layer function at the end of your js:
`sublayers[0].set(options); // altering the SQL and CartoCSS; see above`
Check [the checkpoint code](https://github.com/auremoser/uofm-2015/tree/master/ckpt-4-sqlcss) here if you're stuck. You can also run the SQL in the tray (not in the your local files) and the the map will populate. The advantage to adding it as a template, is that you can swap it for other SQL or run different queries with different template references locally, and you are not limited to one query option.

**Reload your browser window, your map should work!**
## Add Interactivity - Buttons
#### Here's a reference point for this section: [ckpt-4](https://github.com/auremoser/uofm-2015/tree/master/ckpt-4-sqlcss)
To add more interactivity, we'll create two buttons to toggle between the `Simple` map view and the view that gives a choropleth map. We can easily do this in CartoDB by using the `sublayer.setSQL()` and `sublayer.setCartoCSS()` methods to change the data.
First, create another `<style type="cartocss/text" id="simple">` tag set with the following CartoCSS style. Make sure the `id` is set to `simple`.
{% highlight css %}
/** simple visualization */
#tl_2014_census_tracts{
polygon-fill: #5CA2D1;
polygon-opacity: 0.7;
line-color: #FFF;
line-width: 0.25;
line-opacity: 1;
}
{% endhighlight %}
* Next, let's create some buttons. Put the following snippet below the `div` with an `id='map'`.
{% highlight html %}
<div id="cartocss" class="layer_selector">
<p>Layers</p>
<ul>
<li data="choropleth">Water Density Choropleth</li>
<li data="simple">Simple County Map</li>
</ul>
</div>
{% endhighlight %}
* Wire up the buttons with click events:
{% highlight js %}
function createSelector(layer) {
var cartocss = "";
var $options = $(".layer_selector").find("li");
$options.click(function(e) {
var $li = $(e.target);
var selected = $li.attr('data');
$options.removeClass('selected');
$li.addClass('selected');
cartocss = $('#'+selected).text();
layer[0].setCartoCSS(cartocss);
});
}
{% endhighlight %}

Examples:

+ [JSFiddle with Selectors](http://jsfiddle.net/gh/get/library/pure/CartoDB/academy/tree/master/t/03-cartodbjs-ground-up/lesson-3/jsfiddle_demo_cartocss)
+ [Interactivity tutorial](http://docs.cartodb.com/tutorials/custom_interactivity.html)
+ [Advanced example](http://byndhack.herokuapp.com/)
## Infowindows + More
#### Here's a reference point for this section [ckpt-5](https://github.com/auremoser/uofm-2015/tree/master/ckpt-5-buttons)
### Adding infowindows in Editor
You can enable hover infowindows in your editor, that will port to your map and give you some choropleth context.
* customization in html/css
* all data in your table is available to you to populate the tooltips
### Adding infowindows in JS
* HTML templates
* Handlebar notation
* Customizing display of information
* Pulling in images
{% highlight html %}
<script type="infowindow/html" id="infowindow_template">
<div class="cartodb-tooltip-content-wrapper">
<div class="cartodb-tooltip-content">
<h4>Tract:</h4>
<p>{{name}}</p>
<h4>% Water/Tract Area:</h4>
<p>{{perc_water}}</p>
</div>
</div>
</script>
{% endhighlight %}
Then add this to the `options`:
{% highlight js %}
interactivity: 'cartodb_id, name, perc_water'
{% endhighlight %}
After `sublayers[0].set(...)`, add this:
{% highlight js %}
sublayers[0].infowindow.set('template', $('#infowindow_template').html());
{% endhighlight %}
* Click events
* On hover
* On click
You can build on this, or checkout the demo block here to view the result of your work with some limited interactivity!
### Final project here: [Downing Census Map](http://bl.ocks.org/auremoser/f27ed862a4aaf664c31f)

# Building Narrative
Outside of the CartoJS library, we have others to help you build dynamic narrative with your data.
## Tell Time + Stories
**Maps that tell Time** - **[Torque](http://docs.cartodb.com/tutorials/introduction_torque.html)**
<iframe src="https://srogers.cartodb.com/viz/337d9194-6458-11e3-85b5-e5e70547d141/embed_map" width="100%" height="500px"></iframe>
1. [Demonstrations in Brazil](http://blog.cartodb.com/mapping-the-world-ongoing-demonstrations-in-brazil/)
2. Tweets that mention [sunrise map](http://cartodb.s3.amazonaws.com/static_vizz/sunrise.html)
3. [Animal migration patterns](http://robbykraft.github.io/AnimalTrack/)
4. [Beyonce Album Release](https://srogers.cartodb.com/viz/337d9194-6458-11e3-85b5-e5e70547d141/embed_map)
5. [Diwali Celebrated](http://bl.ocks.org/anonymous/raw/b9b7c7d6de1c6398e435/)
6. [Ramadan Tweets w/OdysseyJS](http://bl.ocks.org/anonymous/raw/2f1e9a5a74ceeb88e977/)
7. [Alcatraz Escapees](http://www.washingtonpost.com/news/morning-mix/wp/2014/12/15/the-alcatraz-escapees-could-have-survived-and-this-interactive-model-proves-it/?tid=hp_mm&hpid=z3)
8. [Lynching and the Press](http://yale.cartodb.com/u/mdweaver/viz/ffd06ece-8545-11e4-a898-0e018d66dc29/embed_map)

**Maps that tell Stories** - **[Odyssey JS](http://cartodb.github.io/odyssey.js/index.html)**
1. [Tour of Scotland](http://alasdair.cartodb.com/viz/1332c872-a887-11e4-8c45-0e9d821ea90d/embed_map?zoom=14¢er_lat=55.948595¢er_lon=-3.199913)
2. [*Al Jazeera*: Israeli-Palestinian Conflict by Tweets](http://stream.aljazeera.com/projects/socialmediaconversation/)
3. [The Sounds of 11M](http://www.cadenaser.com/sonidos-11m/)
4. [Berlin Wall Historic Tour](http://bl.ocks.org/namessanti/raw/d5cf706f68b7c6dce9a3/#3)
5. [Maya Angelou Quotes](http://cartodb.com/v/maya-angelou#6)
## Talk Data in Charts
You can use CartoDB's SQL API to query your data and pull it into any charting library of your choosing.
You can easily wire up a chart of census track water density, [check the code here](http://bl.ocks.org/auremoser/9fe84c3f845ea535e7cc).

Learn more about it [here](http://docs.cartodb.com/tips-and-tricks.html#charts--graphs)!
Here are some examples:
Type | Title | Link/Demo | BlogPost
---- |------ | --------- | ---------
[Chart.js](http://www.chartjs.org/) Bar Graph | Traffic Data| [Aurelia's Block](http://bl.ocks.org/auremoser/af95a29cd76267d3925e)
[Highcharts](http://www.highcharts.com/) | Sensor Data | [Github](https://github.com/auremoser/VitalSigns-water/) / [Demo](http://auremoser.github.io/VitalSigns-water/) | [MOW Post](http://blog.cartodb.com/map-of-the-week-pulse-plotting/)
[Highcharts](http://www.highcharts.com/) | Weather Data | [Aurelia's Block](http://bl.ocks.org/auremoser/96b70f6dbcc724ecc973) | [Tutorial](https://stackedit.io/viewer#!provider=gist&gistId=e2d4f0f0b71f258f3ac9&filename=beirut.md)
[Chart.js](http://www.chartjs.org/) Line Graph | Tornado Data | [Andrew's Block](http://bl.ocks.org/andrewxhill/9134155)
[Plot.ly](https://plot.ly/) | Earthquake Data | [Plotly Tutorial](https://plot.ly/ipython-notebooks/cartodb/) | [CartoDB Blog](http://blog.cartodb.com/plotly/)
### More
* `sql.execute(SQL command)` to extract data from your account, place into charts, infowindows, etc.
* Using [Chart.js](http://bl.ocks.org/andrewxhill/9134155)
* `sql.getBounds(SQL command)` to find the bounding box of data returned by SQL command
* [Porpoise Map](http://robbykraft.github.io/AnimalTrack/)
# Resources
##CartoDB
1. [Map Academy](http://academy.cartodb.com)
+ [CartoDB.js](http://academy.cartodb.com/courses/03-cartodbjs-ground-up/lesson-3.html) -- build a web app to visualize your data, allowing for user interaction
+ [SQL and PostGIS](http://academy.cartodb.com/courses/04-sql-postgis.html)
2. [CartoDB Tutorials](http://docs.cartodb.com/tutorials.html)
3. [CartoDB Editor Documentation](http://docs.cartodb.com/cartodb-editor.html)
4. [CartoDB APIs](http://docs.cartodb.com/cartodb-platform.html)
5. [Community help on StackExchange](http://gis.stackexchange.com/questions/tagged/cartodb)
6. [CartoDB Map Gallery](http://cartodb.com/gallery/)
7. [CartoDB Bootstrap Template by Chris Wong](https://github.com/chriswhong/cartodb-github-template)
##Data
1. [Functional street classification DC](http://opendata.dc.gov/datasets/99d13287b85240b89bd46b2aa89e1acf_48)
2. [Open Data DC Transportation](http://opendata.dc.gov/datasets?keyword=transportation)
3. [High Accident Intersection map ughhh pdf](http://ddot.dc.gov/sites/default/files/dc/sites/ddot/publication/attachments/publication_map_high_accident_intersection_09_ddot.pdf)
Current 311 map:

4. [NHTSA Crash Data for Maryland](http://www-fars.nhtsa.dot.gov/States/StatesCrashesAndAllVictims.aspx)
5. [DC GIS Data](http://dcatlas.dcgis.dc.gov/catalog/results.asp?pretype=All&alpha=T)
6. [2030 Proposed Rapid Bus Routes](http://opendata.dc.gov/datasets/99d13287b85240b89bd46b2aa89e1acf_28)
7. [DC Service Requests](http://opendata.dc.gov/datasets/8311590ecf2c4de294c1556c48c2837c_1)
8. [Streetlight Locations](http://opendata.dc.gov/datasets/99d13287b85240b89bd46b2aa89e1acf_90)
9. [Traffic Volume (2006)](http://opendata.dc.gov/datasets/99d13287b85240b89bd46b2aa89e1acf_64)
10. [Transportation Study Areas](http://opendata.dc.gov/datasets/99d13287b85240b89bd46b2aa89e1acf_310)
11. [Council of Governments Traffic Analysis Zones](http://dcatlas.dcgis.dc.gov/catalog/results.asp?pretype=All&pretype_info=&alpha=T&page=2&pagesize=10)
##Visualization
1. [Charting Tools Repository](https://github.com/auremoser/chart-tools)
2. [Workshops @ CartoDB](http://cartodb.github.io/training/)
3. [Recommended tools for Visualizations](http://selection.datavisualization.ch/)
4. [Perception Concerns](https://github.com/tmcw/perception)
5. [Gestalt Theory](http://emeeks.github.io/gestaltdataviz/section1.html)
6. [Color Brewer](http://colorbrewer2.org/) or [Geocolor](http://geocolor.io/)
My contact: [aurelia@cartodb.com](mailto:aurelia@cartodb.com)
If you make a map you're proud of or just want to say hello, connect with me [@auremoser](https://twitter.com/auremoser)
 | ryan-m-cooper/tutorials | _posts/2015-04-20-uofm-workshop.md | Markdown | bsd-2-clause | 37,694 | [
30522,
1011,
1011,
1011,
9621,
1024,
3931,
2516,
1024,
2455,
2883,
7341,
1009,
8083,
4942,
3775,
9286,
1024,
1000,
2118,
1997,
5374,
1024,
3609,
2011,
2193,
11122,
9888,
1000,
4696,
1024,
7783,
3058,
1024,
2325,
1011,
5840,
1011,
2322,
31... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.SQLite;
using System.Data.Common;
using System.IO;
namespace GatherAll
{
class Cls_SqliteMng
{
//string m_DBName = "";
//string connStr = "";
//创建一个数据库文件,保存在当前目录下HyData文件夹下
//
public void CreateDB(string dbName)
{
// string databaseFileName = System.Environment.CurrentDirectory + @"/HyData/" + dbName;
SQLiteConnection.CreateFile(dbName);
}
//执行Sql语句
//创建一个表: ExecuteSql("create table HyTest(TestID TEXT)");
//插入些数据: ExecuteSql("insert into HyTest(TestID) values('1001')");
public void ExecuteSql(string sqlStr, string strConStr)
{
//connStr = connStr1 + m_DBName + connStr;
using (DbConnection conn = new SQLiteConnection(strConStr))
{
conn.Open();
DbCommand comm = conn.CreateCommand();
comm.CommandText = sqlStr;
comm.CommandType = CommandType.Text;
comm.ExecuteNonQuery();
}
}
////执行查询返回DataSet
//private DataSet ExecDataSet(string sqlStr)
//{
// //connStr = "";
// //connStr = connStr1 + m_DBName + connStr;
// using (SQLiteConnection conn = new SQLiteConnection(sqlStr))
// {
// conn.Open();
// SQLiteCommand cmd = conn.CreateCommand();
// cmd.CommandText = sqlStr;
// cmd.CommandType = CommandType.Text;
// SQLiteDataAdapter da = new SQLiteDataAdapter(cmd);
// DataSet ds = new DataSet();
// da.Fill(ds);
// return ds;
// }
//}
}
}
| songboriceboy/GatherAllStoreInDB | GatherAll/Cls_SqliteMng.cs | C# | apache-2.0 | 2,016 | [
30522,
2478,
2291,
1025,
2478,
2291,
1012,
6407,
1012,
12391,
1025,
2478,
2291,
1012,
11409,
4160,
1025,
2478,
2291,
1012,
3793,
1025,
2478,
2291,
1012,
2951,
1025,
2478,
2291,
1012,
2951,
1012,
29296,
4221,
1025,
2478,
2291,
1012,
2951,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
from collections import defaultdict
class Solution(object):
def minWindow(self, S, T):
"""
:type S: str
:type T: str
:rtype: str
"""
pre = defaultdict(list)
for i, c in enumerate(T, -1):
pre[c].append(i)
for val in pre.values():
val.reverse()
start_index = [None] * (len(T) + 1)
lo, hi = float('-inf'), 0
for i, c in enumerate(S):
start_index[-1] = i
for p in pre[c]:
if start_index[p] is not None:
start_index[p + 1] = start_index[p]
if (c == T[-1] and start_index[-2] is not None
and i - start_index[-2] < hi - lo):
lo, hi = start_index[-2], i
if lo < 0:
return ''
else:
return S[lo:hi+1]
# print(Solution().minWindow("abcdebdde", "bde"))
# print(Solution().minWindow("nkzcnhczmccqouqadqtmjjzltgdzthm", "bt"))
print(Solution().minWindow("cnhczmccqouqadqtmjjzl", "mm"))
| wufangjie/leetcode | 727. Minimum Window Subsequence.py | Python | gpl-3.0 | 1,035 | [
30522,
2013,
6407,
12324,
12398,
29201,
2465,
5576,
1006,
4874,
1007,
1024,
13366,
8117,
11101,
5004,
1006,
2969,
1010,
1055,
1010,
1056,
1007,
1024,
1000,
1000,
1000,
1024,
2828,
1055,
1024,
2358,
2099,
1024,
2828,
1056,
1024,
2358,
2099,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
<?php
/**
* @package Joomla.UnitTest
* @subpackage Crypt
*
* @copyright Copyright (C) 2005 - 2017 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
/**
* Test class for JCryptCipherCrypto.
*/
class JCryptCipherCryptoTest extends TestCase
{
/**
* This method is called before the first test of this test class is run.
*
* @return void
*/
public static function setUpBeforeClass()
{
// Only run the test if the environment supports it.
try
{
Crypto::RuntimeTest();
}
catch (CryptoTestFailedException $e)
{
self::markTestSkipped('The environment cannot safely perform encryption with this cipher.');
}
}
/**
* Test data for processing
*
* @return array
*/
public function dataStrings()
{
return array(
array('c-;3-(Is>{DJzOHMCv_<#yKuN/G`/Us{GkgicWG$M|HW;kI0BVZ^|FY/"Obt53?PNaWwhmRtH;lWkWE4vlG5CIFA!abu&F=Xo#Qw}gAp3;GL\'k])%D}C+W&ne6_F$3P5'),
array('Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. ' .
'Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor ' .
'in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt ' .
'in culpa qui officia deserunt mollit anim id est laborum.'),
array('لا أحد يحب الألم بذاته، يسعى ورائه أو يبتغيه، ببساطة لأنه الألم...'),
array('Широкая электрификация южных губерний даст мощный толчок подъёму сельского хозяйства'),
array('The quick brown fox jumps over the lazy dog.')
);
}
/**
* @testdox Validates data is encrypted and decrypted correctly
*
* @param string $data The decrypted data to validate
*
* @covers JCryptCipherCrypto::decrypt
* @covers JCryptCipherCrypto::encrypt
* @dataProvider dataStrings
*/
public function testDataEncryptionAndDecryption($data)
{
$cipher = new JCryptCipherCrypto;
$key = $cipher->generateKey();
$encrypted = $cipher->encrypt($data, $key);
// Assert that the encrypted value is not the same as the clear text value.
$this->assertNotSame($data, $encrypted);
$decrypted = $cipher->decrypt($encrypted, $key);
// Assert the decrypted string is the same value we started with
$this->assertSame($data, $decrypted);
}
/**
* @testdox Validates keys are correctly generated
*
* @covers JCryptCipherCrypto::generateKey
*/
public function testGenerateKey()
{
$cipher = new JCryptCipherCrypto;
$key = $cipher->generateKey();
// Assert that the key is the correct type.
$this->assertInstanceOf('JCryptKey', $key);
// Assert the private key is our expected value.
$this->assertSame('unused', $key->private);
// Assert the public key is the expected length
$this->assertSame(Crypto::KEY_BYTE_SIZE, JCrypt::safeStrlen($key->public));
// Assert the key is of the correct type.
$this->assertAttributeEquals('crypto', 'type', $key);
}
}
| schnuti/joomla-cms | tests/unit/suites/libraries/joomla/crypt/cipher/JCryptCipherCryptoTest.php | PHP | gpl-2.0 | 3,222 | [
30522,
1026,
1029,
25718,
1013,
1008,
1008,
1008,
1030,
7427,
28576,
19968,
2050,
1012,
3131,
22199,
1008,
1030,
4942,
23947,
4270,
19888,
1008,
1008,
1030,
9385,
9385,
1006,
1039,
1007,
2384,
1011,
2418,
2330,
3120,
5609,
1010,
4297,
1012,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
<?php
/**
* Controls how events are queried and displayed via the WordPress Custom Post APIs
* @author marcus
*
*/
class EM_Event_Post {
function init(){
global $wp_query;
//Front Side Modifiers
if( !is_admin() ){
//override single page with formats?
add_filter('the_content', array('EM_Event_Post','the_content'));
add_filter('the_excerpt_rss', array('EM_Event_Post','the_excerpt_rss'));
//display as page template?
if( get_option('dbem_cp_events_template') ){
add_filter('single_template',array('EM_Event_Post','single_template'));
}
//add classes to body and post_class()
if( get_option('dbem_cp_events_post_class') != '' ){
add_filter('post_class', array('EM_Event_Post','post_class'), 10, 3);
}
if( get_option('dbem_cp_events_body_class') != '' ){
add_filter('body_class', array('EM_Event_Post','body_class'), 10, 3);
}
//Override post template tags
add_filter('the_date',array('EM_Event_Post','the_date'),10,2);
add_filter('get_the_date',array('EM_Event_Post','the_date'),10,2);
add_filter('the_time',array('EM_Event_Post','the_time'),10,2);
add_filter('get_the_time',array('EM_Event_Post','the_time'),10,2);
add_filter('the_category',array('EM_Event_Post','the_category'),10,3);
}
add_action('parse_query', array('EM_Event_Post','parse_query'));
add_action('publish_future_post',array('EM_Event_Post','publish_future_post'),10,1);
}
function publish_future_post($post_id){
global $wpdb, $EM_Event, $EM_Location, $EM_Notices;
$post_type = get_post_type($post_id);
$is_post_type = $post_type == EM_POST_TYPE_EVENT || $post_type == 'event-recurring';
$saving_status = !in_array(get_post_status($post_id), array('trash','auto-draft')) && !defined('DOING_AUTOSAVE');
if(!defined('UNTRASHING_'.$post_id) && $is_post_type && $saving_status ){
$EM_Event = em_get_event($post_id, 'post_id');
$EM_Event->set_status(1);
}
}
/**
* Overrides the default post format of an event and can display an event as a page, which uses the page.php template.
* @param string $template
* @return string
*/
function single_template($template){
global $post;
if( !locate_template('single-'.EM_POST_TYPE_EVENT.'.php') && $post->post_type == EM_POST_TYPE_EVENT ){
//do we have a default template to choose for events?
if( get_option('dbem_cp_events_template') == 'page' ){
$post_templates = array('page.php','index.php');
}else{
$post_templates = array(get_option('dbem_cp_events_template'));
}
if( !empty($post_templates) ){
$post_template = locate_template($post_templates,false);
if( !empty($post_template) ) $template = $post_template;
}
}
return $template;
}
function post_class( $classes, $class, $post_id ){
$post = get_post($post_id);
if( $post->post_type == EM_POST_TYPE_EVENT ){
foreach( explode(' ', get_option('dbem_cp_events_post_class')) as $class ){
$classes[] = esc_attr($class);
}
}
return $classes;
}
function body_class( $classes ){
if( em_is_event_page() ){
foreach( explode(' ', get_option('dbem_cp_events_body_class')) as $class ){
$classes[] = esc_attr($class);
}
}
return $classes;
}
function the_excerpt_rss( $content ){
global $post, $EM_Event;
if( $post->post_type == EM_POST_TYPE_EVENT ){
if( get_option('dbem_cp_events_formats') ){
$EM_Event = em_get_event($post);
$content = $EM_Event->output( get_option ( 'dbem_rss_description_format' ), "rss");
$content = ent2ncr(convert_chars($content)); //Some RSS filtering
}
}
return $content;
}
function the_content( $content ){
global $post, $EM_Event;
if( $post->post_type == EM_POST_TYPE_EVENT ){
if( is_archive() || is_search() ){
if(get_option('dbem_cp_events_archive_formats')){
$EM_Event = em_get_event($post);
$content = $EM_Event->output(get_option('dbem_event_list_item_format'));
}
}else{
if( get_option('dbem_cp_events_formats') && !post_password_required() ){
$EM_Event = em_get_event($post);
ob_start();
em_locate_template('templates/event-single.php',true);
$content = ob_get_clean();
}elseif( !post_password_required() ){
$EM_Event = em_get_event($post);
if( $EM_Event->event_rsvp ){
$content .= $EM_Event->output('<h2>Bookings</h2>#_BOOKINGFORM');
}
}
}
}
return $content;
}
function the_date( $the_date, $d = '' ){
global $post;
if( $post->post_type == EM_POST_TYPE_EVENT ){
$EM_Event = em_get_event($post);
if ( '' == $d ){
$the_date = date_i18n(get_option('date_format'), $EM_Event->start);
}else{
$the_date = date_i18n($d, $EM_Event->start);
}
}
return $the_date;
}
function the_time( $the_time, $f = '' ){
global $post;
if( $post->post_type == EM_POST_TYPE_EVENT ){
$EM_Event = em_get_event($post);
if ( '' == $f ){
$the_time = date_i18n(get_option('time_format'), $EM_Event->start);
}else{
$the_time = date_i18n($f, $EM_Event->start);
}
}
return $the_time;
}
function the_category( $thelist, $separator = '', $parents='' ){
global $post, $wp_rewrite;
if( $post->post_type == EM_POST_TYPE_EVENT ){
$EM_Event = em_get_event($post);
$categories = $EM_Event->get_categories();
if( empty($categories) ) return '';
/* Copied from get_the_category_list function, with a few minor edits to make urls work, and removing parent stuff (for now) */
$rel = ( is_object( $wp_rewrite ) && $wp_rewrite->using_permalinks() ) ? 'rel="category tag"' : 'rel="category"';
$thelist = '';
if ( '' == $separator ) {
$thelist .= '<ul class="post-categories">';
foreach ( $categories as $category ) {
$thelist .= "\n\t<li>";
switch ( strtolower( $parents ) ) {
case 'multiple':
$thelist .= '<a href="' . $category->get_url() . '" title="' . esc_attr( sprintf( __( "View all posts in %s", 'dbem' ), $category->name ) ) . '" ' . $rel . '>' . $category->name.'</a></li>';
break;
case 'single':
$thelist .= '<a href="' . $category->get_url() . '" title="' . esc_attr( sprintf( __( "View all posts in %s", 'dbem' ), $category->name ) ) . '" ' . $rel . '>';
$thelist .= $category->name.'</a></li>';
break;
case '':
default:
$thelist .= '<a href="' . $category->get_url() . '" title="' . esc_attr( sprintf( __( "View all posts in %s", 'dbem' ), $category->name ) ) . '" ' . $rel . '>' . $category->name.'</a></li>';
}
}
$thelist .= '</ul>';
} else {
$i = 0;
foreach ( $categories as $category ) {
if ( 0 < $i )
$thelist .= $separator;
switch ( strtolower( $parents ) ) {
case 'multiple':
$thelist .= '<a href="' . $category->get_url() . '" title="' . esc_attr( sprintf( __( "View all posts in %s", 'dbem' ), $category->name ) ) . '" ' . $rel . '>' . $category->name.'</a>';
break;
case 'single':
$thelist .= '<a href="' . $category->get_url() . '" title="' . esc_attr( sprintf( __( "View all posts in %s", 'dbem' ), $category->name ) ) . '" ' . $rel . '>';
$thelist .= "$category->name</a>";
break;
case '':
default:
$thelist .= '<a href="' . $category->get_url() . '" title="' . esc_attr( sprintf( __( "View all posts in %s", 'dbem' ), $category->name ) ) . '" ' . $rel . '>' . $category->name.'</a>';
}
++$i;
}
}
/* End copying */
}
return $thelist;
}
function parse_query(){
global $wp_query;
//Search Query Filtering
if( is_admin() ){
if( !empty($wp_query->query_vars[EM_TAXONOMY_CATEGORY]) && is_numeric($wp_query->query_vars[EM_TAXONOMY_CATEGORY]) ){
//sorts out filtering admin-side as it searches by id
$term = get_term_by('id', $wp_query->query_vars[EM_TAXONOMY_CATEGORY], EM_TAXONOMY_CATEGORY);
$wp_query->query_vars[EM_TAXONOMY_CATEGORY] = ( $term !== false && !is_wp_error($term) )? $term->slug:0;
}
}
//Scoping
if( !empty($wp_query->query_vars['post_type']) && ($wp_query->query_vars['post_type'] == EM_POST_TYPE_EVENT || $wp_query->query_vars['post_type'] == 'event-recurring') && (empty($wp_query->query_vars['post_status']) || !in_array($wp_query->query_vars['post_status'],array('trash','pending','draft'))) ) {
//Let's deal with the scope - default is future
if( is_admin() ){
$scope = $wp_query->query_vars['scope'] = (!empty($_REQUEST['scope'])) ? $_REQUEST['scope']:'future';
//TODO limit what a user can see admin side for events/locations/recurring events
}else{
if( !empty($wp_query->query_vars['calendar_day']) ) $wp_query->query_vars['scope'] = $wp_query->query_vars['calendar_day'];
if( empty($wp_query->query_vars['scope']) ){
if( is_archive() ){
$scope = $wp_query->query_vars['scope'] = get_option('dbem_events_archive_scope');
}else{
$scope = $wp_query->query_vars['scope'] = 'all'; //otherwise we'll get 404s for past events
}
}else{
$scope = $wp_query->query_vars['scope'];
}
}
$query = array();
$time = current_time('timestamp');
if ( preg_match ( "/^[0-9]{4}-[0-9]{2}-[0-9]{2}$/", $scope ) ) {
$today = strtotime($scope);
$tomorrow = $today + 60*60*24-1;
if( get_option('dbem_events_current_are_past') && $wp_query->query_vars['post_type'] != 'event-recurring' ){
$query[] = array( 'key' => '_start_ts', 'value' => array($today,$tomorrow), 'compare' => 'BETWEEN' );
}else{
$query[] = array( 'key' => '_start_ts', 'value' => $tomorrow, 'compare' => '<=' );
$query[] = array( 'key' => '_end_ts', 'value' => $today, 'compare' => '>=' );
}
}elseif ($scope == "future"){
$today = strtotime(date('Y-m-d', $time));
if( get_option('dbem_events_current_are_past') && $wp_query->query_vars['post_type'] != 'event-recurring' ){
$query[] = array( 'key' => '_start_ts', 'value' => $today, 'compare' => '>=' );
}else{
$query[] = array( 'key' => '_end_ts', 'value' => $today, 'compare' => '>=' );
}
}elseif ($scope == "past"){
$today = strtotime(date('Y-m-d', $time));
if( get_option('dbem_events_current_are_past') && $wp_query->query_vars['post_type'] != 'event-recurring' ){
$query[] = array( 'key' => '_start_ts', 'value' => $today, 'compare' => '<' );
}else{
$query[] = array( 'key' => '_end_ts', 'value' => $today, 'compare' => '<' );
}
}elseif ($scope == "today"){
$today = strtotime(date('Y-m-d', $time));
$tomorrow = strtotime(date('Y-m-d',$time+60*60*24));
if( get_option('dbem_events_current_are_past') && $wp_query->query_vars['post_type'] != 'event-recurring' ){
//date must be only today
$query[] = array( 'key' => '_start_ts', 'value' => array($today, $tomorrow), 'compare' => 'BETWEEN');
}else{
$query[] = array( 'key' => '_start_ts', 'value' => $tomorrow, 'compare' => '<' );
$query[] = array( 'key' => '_end_ts', 'value' => $today, 'compare' => '>=' );
}
}elseif ($scope == "tomorrow"){
$tomorrow = strtotime(date('Y-m-d',$time+60*60*24));
$after_tomorrow = $tomorrow + 60*60*24;
if( get_option('dbem_events_current_are_past') && $wp_query->query_vars['post_type'] != 'event-recurring' ){
//date must be only tomorrow
$query[] = array( 'key' => '_start_ts', 'value' => array($tomorrow, $after_tomorrow), 'compare' => 'BETWEEN');
}else{
$query[] = array( 'key' => '_start_ts', 'value' => $after_tomorrow, 'compare' => '<' );
$query[] = array( 'key' => '_end_ts', 'value' => $tomorrow, 'compare' => '>=' );
}
}elseif ($scope == "month"){
$start_month = strtotime(date('Y-m-d',$time));
$end_month = strtotime(date('Y-m-t',$time)) + 86399;
if( get_option('dbem_events_current_are_past') && $wp_query->query_vars['post_type'] != 'event-recurring' ){
$query[] = array( 'key' => '_start_ts', 'value' => array($start_month,$end_month), 'type' => 'numeric', 'compare' => 'BETWEEN');
}else{
$query[] = array( 'key' => '_start_ts', 'value' => $end_month, 'compare' => '<=' );
$query[] = array( 'key' => '_end_ts', 'value' => $start_month, 'compare' => '>=' );
}
}elseif ($scope == "next-month"){
$start_month_timestamp = strtotime('+1 month', $time); //get the end of this month + 1 day
$start_month = strtotime(date('Y-m-1',$start_month_timestamp));
$end_month = strtotime(date('Y-m-t',$start_month_timestamp)) + 86399;
if( get_option('dbem_events_current_are_past') && $wp_query->query_vars['post_type'] != 'event-recurring' ){
$query[] = array( 'key' => '_start_ts', 'value' => array($start_month,$end_month), 'type' => 'numeric', 'compare' => 'BETWEEN');
}else{
$query[] = array( 'key' => '_start_ts', 'value' => $end_month, 'compare' => '<=' );
$query[] = array( 'key' => '_end_ts', 'value' => $start_month, 'compare' => '>=' );
}
}elseif( preg_match('/(\d\d?)\-months/',$scope,$matches) ){ // next x months means this month (what's left of it), plus the following x months until the end of that month.
$months_to_add = $matches[1];
$start_month = strtotime(date('Y-m-d',$time));
$end_month = strtotime(date('Y-m-t',strtotime("+$months_to_add month", $time))) + 86399;
if( get_option('dbem_events_current_are_past') && $wp_query->query_vars['post_type'] != 'event-recurring' ){
$query[] = array( 'key' => '_start_ts', 'value' => array($start_month,$end_month), 'type' => 'numeric', 'compare' => 'BETWEEN');
}else{
$query[] = array( 'key' => '_start_ts', 'value' => $end_month, 'compare' => '<=' );
$query[] = array( 'key' => '_end_ts', 'value' => $start_month, 'compare' => '>=' );
}
}
if( !empty($query) && is_array($query) ){
$wp_query->query_vars['meta_query'] = $query;
}
if( is_admin() ){
//admin areas don't need special ordering, so make it simple
$wp_query->query_vars['orderby'] = (!empty($_REQUEST['orderby'])) ? $_REQUEST['orderby']:'meta_value_num';
$wp_query->query_vars['meta_key'] = '_start_ts';
$wp_query->query_vars['order'] = (!empty($_REQUEST['order'])) ? $_REQUEST['order']:'ASC';
}else{
if( get_option('dbem_events_default_archive_orderby') == 'title'){
$wp_query->query_vars['orderby'] = 'title';
$wp_query->query_vars['order'] = get_option('dbem_events_default_archive_order','ASC');
}else{
$wp_query->query_vars['orderby'] = 'meta_value_num';
$wp_query->query_vars['meta_key'] = '_start_ts';
}
$wp_query->query_vars['order'] = get_option('dbem_events_default_archive_order','ASC');
}
}elseif( !empty($wp_query->query_vars['post_type']) && $wp_query->query_vars['post_type'] == EM_POST_TYPE_EVENT ){
$wp_query->query_vars['scope'] = 'all';
if( $wp_query->query_vars['post_status'] == 'pending' ){
$wp_query->query_vars['orderby'] = 'meta_value_num';
$wp_query->query_vars['order'] = 'ASC';
$wp_query->query_vars['meta_key'] = '_start_ts';
}
}
}
}
EM_Event_Post::init(); | daedaluss/Nazareth | wp-content/plugins/events-manager/classes/em-event-post.php | PHP | gpl-2.0 | 15,069 | [
30522,
1026,
1029,
25718,
1013,
1008,
1008,
1008,
7711,
2129,
2824,
2024,
10861,
11998,
1998,
6913,
3081,
1996,
2773,
20110,
7661,
2695,
17928,
2015,
1008,
1030,
3166,
6647,
1008,
1008,
1013,
2465,
7861,
1035,
2724,
1035,
2695,
1063,
3853,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
/* Copyright (C) 2002-2014 Free Software Foundation, Inc.
Contributed by Andy Vaught and Paul Brook <paul@nowt.org>
This file is part of the GNU Fortran runtime library (libgfortran).
Libgfortran is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3, or (at your option)
any later version.
Libgfortran is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
Under Section 7 of GPL version 3, you are granted additional
permissions described in the GCC Runtime Library Exception, version
3.1, as published by the Free Software Foundation.
You should have received a copy of the GNU General Public License and
a copy of the GCC Runtime Library Exception along with this program;
see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
<http://www.gnu.org/licenses/>. */
#include "libgfortran.h"
#include <stdlib.h>
#include <string.h>
#include <limits.h>
#include <errno.h>
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
/* Stupid function to be sure the constructor is always linked in, even
in the case of static linking. See PR libfortran/22298 for details. */
void
stupid_function_name_for_static_linking (void)
{
return;
}
/* This will be 0 for little-endian
machines and 1 for big-endian machines. */
int big_endian = 0;
/* Figure out endianness for this machine. */
static void
determine_endianness (void)
{
union
{
GFC_LOGICAL_8 l8;
GFC_LOGICAL_4 l4[2];
} u;
u.l8 = 1;
if (u.l4[0])
big_endian = 0;
else if (u.l4[1])
big_endian = 1;
else
runtime_error ("Unable to determine machine endianness");
}
static int argc_save;
static char **argv_save;
static const char *exe_path;
static bool please_free_exe_path_when_done;
/* Save the path under which the program was called, for use in the
backtrace routines. */
void
store_exe_path (const char * argv0)
{
#ifndef DIR_SEPARATOR
#define DIR_SEPARATOR '/'
#endif
char *cwd, *path;
/* This can only happen if store_exe_path is called multiple times. */
if (please_free_exe_path_when_done)
free ((char *) exe_path);
/* Reading the /proc/self/exe symlink is Linux-specific(?), but if
it works it gives the correct answer. */
#ifdef HAVE_READLINK
ssize_t len, psize = 256;
while (1)
{
path = xmalloc (psize);
len = readlink ("/proc/self/exe", path, psize);
if (len < 0)
{
free (path);
break;
}
else if (len < psize)
{
path[len] = '\0';
exe_path = strdup (path);
free (path);
please_free_exe_path_when_done = true;
return;
}
/* The remaining option is len == psize. */
free (path);
psize *= 4;
}
#endif
/* If the path is absolute or on a simulator where argv is not set. */
#ifdef __MINGW32__
if (argv0 == NULL
|| ('A' <= argv0[0] && argv0[0] <= 'Z' && argv0[1] == ':')
|| ('a' <= argv0[0] && argv0[0] <= 'z' && argv0[1] == ':')
|| (argv0[0] == '/' && argv0[1] == '/')
|| (argv0[0] == '\\' && argv0[1] == '\\'))
#else
if (argv0 == NULL || argv0[0] == DIR_SEPARATOR)
#endif
{
exe_path = argv0;
please_free_exe_path_when_done = false;
return;
}
#ifdef HAVE_GETCWD
size_t cwdsize = 256;
while (1)
{
cwd = xmalloc (cwdsize);
if (getcwd (cwd, cwdsize))
break;
else if (errno == ERANGE)
{
free (cwd);
cwdsize *= 4;
}
else
{
free (cwd);
cwd = NULL;
break;
}
}
#else
cwd = NULL;
#endif
if (!cwd)
{
exe_path = argv0;
please_free_exe_path_when_done = false;
return;
}
/* exe_path will be cwd + "/" + argv[0] + "\0". This will not work
if the executable is not in the cwd, but at this point we're out
of better ideas. */
size_t pathlen = strlen (cwd) + 1 + strlen (argv0) + 1;
path = xmalloc (pathlen);
snprintf (path, pathlen, "%s%c%s", cwd, DIR_SEPARATOR, argv0);
free (cwd);
exe_path = path;
please_free_exe_path_when_done = true;
}
/* Return the full path of the executable. */
char *
full_exe_path (void)
{
return (char *) exe_path;
}
char *addr2line_path;
/* Find addr2line and store the path. */
void
find_addr2line (void)
{
#ifdef HAVE_ACCESS
#define A2L_LEN 10
char *path = secure_getenv ("PATH");
if (!path)
return;
size_t n = strlen (path);
char ap[n + 1 + A2L_LEN];
size_t ai = 0;
for (size_t i = 0; i < n; i++)
{
if (path[i] != ':')
ap[ai++] = path[i];
else
{
ap[ai++] = '/';
memcpy (ap + ai, "addr2line", A2L_LEN);
if (access (ap, R_OK|X_OK) == 0)
{
addr2line_path = strdup (ap);
return;
}
else
ai = 0;
}
}
#endif
}
/* Set the saved values of the command line arguments. */
void
set_args (int argc, char **argv)
{
argc_save = argc;
argv_save = argv;
store_exe_path (argv[0]);
}
iexport(set_args);
/* Retrieve the saved values of the command line arguments. */
void
get_args (int *argc, char ***argv)
{
*argc = argc_save;
*argv = argv_save;
}
/* Initialize the runtime library. */
static void __attribute__((constructor))
init (void)
{
/* Figure out the machine endianness. */
determine_endianness ();
/* Must be first */
init_variables ();
init_units ();
set_fpu ();
init_compile_options ();
#ifdef DEBUG
/* Check for special command lines. */
if (argc > 1 && strcmp (argv[1], "--help") == 0)
show_variables ();
/* if (argc > 1 && strcmp(argv[1], "--resume") == 0) resume(); */
#endif
if (options.backtrace == 1)
find_addr2line ();
random_seed_i4 (NULL, NULL, NULL);
}
/* Cleanup the runtime library. */
static void __attribute__((destructor))
cleanup (void)
{
close_units ();
if (please_free_exe_path_when_done)
free ((char *) exe_path);
free (addr2line_path);
}
| embecosm/avr-gcc | libgfortran/runtime/main.c | C | gpl-2.0 | 6,031 | [
30522,
1013,
1008,
9385,
1006,
1039,
1007,
2526,
1011,
2297,
2489,
4007,
3192,
1010,
4297,
1012,
5201,
2011,
5557,
12436,
18533,
1998,
2703,
9566,
1026,
2703,
1030,
2085,
2102,
1012,
8917,
1028,
2023,
5371,
2003,
2112,
1997,
1996,
27004,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.