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 |
|---|---|---|---|---|---|---|---|---|---|
/* $Id$ */
/***************************************************************************
* (C) Copyright 2003 - Marauroa *
***************************************************************************
***************************************************************************
* *
* 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. *
* *
***************************************************************************/
package games.stendhal.client.gui.login;
import games.stendhal.client.StendhalClient;
import games.stendhal.client.stendhal;
import games.stendhal.client.gui.ProgressBar;
import games.stendhal.client.gui.WindowUtils;
import games.stendhal.client.gui.layout.SBoxLayout;
import games.stendhal.client.sprite.DataLoader;
import games.stendhal.client.update.ClientGameConfiguration;
import java.awt.Component;
import java.awt.Frame;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Insets;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyEvent;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.URL;
import javax.swing.BorderFactory;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JComboBox;
import javax.swing.JComponent;
import javax.swing.JDialog;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPasswordField;
import javax.swing.JTextField;
import javax.swing.SwingUtilities;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import javax.swing.event.DocumentEvent;
import javax.swing.event.DocumentListener;
import javax.swing.text.Document;
import marauroa.client.BannedAddressException;
import marauroa.client.LoginFailedException;
import marauroa.client.TimeoutException;
import marauroa.common.io.Persistence;
import marauroa.common.net.InvalidVersionException;
import marauroa.common.net.message.MessageS2CLoginNACK;
import org.apache.log4j.Logger;
/**
* Server login dialog.
*
*/
public class LoginDialog extends JDialog {
private static final long serialVersionUID = -1182930046629241075L;
private ProfileList profiles;
private JComboBox profilesComboBox;
private JCheckBox saveLoginBox;
private JCheckBox savePasswordBox;
private JTextField usernameField;
private JPasswordField passwordField;
private JTextField serverField;
private JTextField serverPortField;
private JButton loginButton;
private JButton removeButton;
// End of variables declaration
private final StendhalClient client;
private ProgressBar progressBar;
// Object checking that all required fields are filled
private DataValidator fieldValidator;
/**
* Create a new LoginDialog.
*
* @param owner parent window
* @param client client
*/
public LoginDialog(final Frame owner, final StendhalClient client) {
super(owner, true);
this.client = client;
initializeComponent();
WindowUtils.closeOnEscape(this);
}
/**
* Create the dialog contents.
*/
private void initializeComponent() {
this.addWindowListener(new WindowAdapter() {
@Override
public void windowClosing(WindowEvent e) {
if (getOwner() == null) {
System.exit(0);
}
getOwner().setEnabled(true);
dispose();
}
});
JLabel l;
this.setTitle("Login to Server");
this.setResizable(false);
//
// contentPane
//
JComponent contentPane = (JComponent) getContentPane();
contentPane.setLayout(new GridBagLayout());
final int pad = SBoxLayout.COMMON_PADDING;
contentPane.setBorder(BorderFactory.createEmptyBorder(pad, pad, pad, pad));
final GridBagConstraints c = new GridBagConstraints();
c.anchor = GridBagConstraints.LINE_START;
/*
* Profiles
*/
l = new JLabel("Account profiles");
c.insets = new Insets(4, 4, 15, 4);
// column
c.gridx = 0;
// row
c.gridy = 0;
contentPane.add(l, c);
profilesComboBox = new JComboBox();
profilesComboBox.addActionListener(new ProfilesCB());
/*
* Remove profile button
*/
removeButton = createRemoveButton();
// Container for the profiles list and the remove button
JComponent box = SBoxLayout.createContainer(SBoxLayout.HORIZONTAL, pad);
profilesComboBox.setAlignmentY(Component.CENTER_ALIGNMENT);
box.add(profilesComboBox);
box.add(removeButton);
c.gridx = 1;
c.gridy = 0;
c.fill = GridBagConstraints.BOTH;
contentPane.add(box, c);
/*
* Server Host
*/
l = new JLabel("Server name");
c.insets = new Insets(4, 4, 4, 4);
// column
c.gridx = 0;
// row
c.gridy = 1;
contentPane.add(l, c);
serverField = new JTextField(
ClientGameConfiguration.get("DEFAULT_SERVER"));
c.gridx = 1;
c.gridy = 1;
c.fill = GridBagConstraints.BOTH;
contentPane.add(serverField, c);
/*
* Server Port
*/
l = new JLabel("Server port");
c.insets = new Insets(4, 4, 4, 4);
c.gridx = 0;
c.gridy = 2;
contentPane.add(l, c);
serverPortField = new JTextField(
ClientGameConfiguration.get("DEFAULT_PORT"));
c.gridx = 1;
c.gridy = 2;
c.insets = new Insets(4, 4, 4, 4);
c.fill = GridBagConstraints.BOTH;
contentPane.add(serverPortField, c);
/*
* Username
*/
l = new JLabel("Type your username");
c.insets = new Insets(4, 4, 4, 4);
c.gridx = 0;
c.gridy = 3;
contentPane.add(l, c);
usernameField = new JTextField();
c.gridx = 1;
c.gridy = 3;
c.fill = GridBagConstraints.BOTH;
contentPane.add(usernameField, c);
/*
* Password
*/
l = new JLabel("Type your password");
c.gridx = 0;
c.gridy = 4;
c.fill = GridBagConstraints.NONE;
contentPane.add(l, c);
passwordField = new JPasswordField();
c.gridx = 1;
c.gridy = 4;
c.fill = GridBagConstraints.BOTH;
contentPane.add(passwordField, c);
/*
* Save Profile/Login
*/
saveLoginBox = new JCheckBox("Save login profile locally");
saveLoginBox.setSelected(false);
c.gridx = 0;
c.gridy = 5;
c.fill = GridBagConstraints.NONE;
contentPane.add(saveLoginBox, c);
/*
* Save Profile Password
*/
savePasswordBox = new JCheckBox("Save password");
savePasswordBox.setSelected(true);
savePasswordBox.setEnabled(false);
c.gridx = 0;
c.gridy = 6;
c.fill = GridBagConstraints.NONE;
c.insets = new Insets(0, 20, 0, 0);
contentPane.add(savePasswordBox, c);
loginButton = new JButton();
loginButton.setText("Login to Server");
loginButton.setMnemonic(KeyEvent.VK_L);
this.rootPane.setDefaultButton(loginButton);
loginButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(final ActionEvent e) {
loginButtonActionPerformed();
}
});
c.gridx = 1;
c.gridy = 5;
c.gridheight = 2;
c.anchor = GridBagConstraints.CENTER;
c.insets = new Insets(15, 4, 4, 4);
contentPane.add(loginButton, c);
// Before loading profiles so that we can catch the data filled from
// there
bindEditListener();
/*
* Load saved profiles
*/
profiles = loadProfiles();
populateProfiles(profiles);
/*
* Add this callback after everything is initialized
*/
saveLoginBox.addChangeListener(new SaveProfileStateCB());
//
// Dialog
//
this.pack();
usernameField.requestFocusInWindow();
if (getOwner() != null) {
getOwner().setEnabled(false);
this.setLocationRelativeTo(getOwner());
}
}
/**
* Prepare the field validator and bind it to the relevant text fields.
*/
private void bindEditListener() {
fieldValidator = new DataValidator(loginButton,
serverField.getDocument(), serverPortField.getDocument(),
usernameField.getDocument(), passwordField.getDocument());
}
/**
* Create the remove character button.
*
* @return JButton
*/
private JButton createRemoveButton() {
final URL url = DataLoader.getResource("data/gui/trash.png");
ImageIcon icon = new ImageIcon(url);
JButton button = new JButton(icon);
// Clear the margins that buttons normally add
button.setMargin(new Insets(0, 0, 0, 0));
button.setToolTipText("Remove the selected account from the list");
button.addActionListener(new ActionListener() {
@Override
public void actionPerformed(final ActionEvent e) {
removeButtonActionPerformed();
}
});
return button;
}
/**
* Called when the login button is activated.
*/
private void loginButtonActionPerformed() {
// If this window isn't enabled, we shouldn't act.
if (!isEnabled()) {
return;
}
setEnabled(false);
Profile profile;
profile = new Profile();
profile.setHost((serverField.getText()).trim());
try {
profile.setPort(Integer.parseInt(serverPortField.getText().trim()));
// Support for saving port number. Only save when input is a number
// intensifly@gmx.com
} catch (final NumberFormatException ex) {
JOptionPane.showMessageDialog(this,
"That is not a valid port number. Please try again.",
"Invalid port", JOptionPane.WARNING_MESSAGE);
return;
}
profile.setUser(usernameField.getText().trim());
profile.setPassword(new String(passwordField.getPassword()));
/*
* Save profile?
*/
if (saveLoginBox.isSelected()) {
profiles.add(profile);
populateProfiles(profiles);
if (savePasswordBox.isSelected()) {
saveProfiles(profiles);
} else {
final String pw = profile.getPassword();
profile.setPassword("");
saveProfiles(profiles);
profile.setPassword(pw);
}
}
/*
* Run the connection procces in separate thread. added by TheGeneral
*/
final Thread t = new Thread(new ConnectRunnable(profile), "Login");
t.start();
}
/**
* Called when the remove profile button is activated.
*/
private void removeButtonActionPerformed() {
// If this window isn't enabled, we shouldn't act.
if (!isEnabled() || (profiles.profiles.size() == 0)) {
return;
}
setEnabled(false);
Profile profile;
profile = (Profile) profilesComboBox.getSelectedItem();
Object[] options = { "Remove", "Cancel" };
Integer confirmRemoveProfile = JOptionPane.showOptionDialog(this,
"This will permanently remove a user profile from your local list of accounts.\n"
+ "It will not delete an account on any servers.\n"
+ "Are you sure you want to remove \'" + profile.getUser() + "@" + profile.getHost() + "\' profile?",
"Remove user profile from local list of accounts",
JOptionPane.OK_CANCEL_OPTION,
JOptionPane.QUESTION_MESSAGE,
null,
options,
options[1]);
if (confirmRemoveProfile == 0) {
profiles.remove(profile);
saveProfiles(profiles);
profiles = loadProfiles();
populateProfiles(profiles);
}
setEnabled(true);
}
@Override
public void setEnabled(final boolean b) {
super.setEnabled(b);
// Enabling login button is conditional
fieldValidator.revalidate();
removeButton.setEnabled(b);
}
/**
* Connect to a server using a given profile.
*
* @param profile profile used for login
*/
public void connect(final Profile profile) {
// We are not in EDT
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
progressBar = new ProgressBar(LoginDialog.this);
progressBar.start();
}
});
try {
client.connect(profile.getHost(), profile.getPort());
// for each major connection milestone call step(). progressBar is
// created in EDT, so it is not guaranteed non null in the main
// thread.
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
progressBar.step();
}
});
} catch (final Exception ex) {
// if something goes horribly just cancel the progressbar
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
progressBar.cancel();
setEnabled(true);
}
});
String message = "unable to connect to server";
if (profile != null) {
message = message + " " + profile.getHost() + ":" + profile.getPort();
} else {
message = message + ", because profile was null";
}
Logger.getLogger(LoginDialog.class).error(message, ex);
handleError("Unable to connect to server. Did you misspell the server name?", "Connection failed");
return;
}
try {
client.setAccountUsername(profile.getUser());
client.setCharacter(profile.getCharacter());
client.login(profile.getUser(), profile.getPassword(), profile.getSeed());
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
progressBar.finish();
// workaround near failures in AWT at openjdk (tested on openjdk-1.6.0.0)
try {
setVisible(false);
} catch (NullPointerException npe) {
Logger.getLogger(LoginDialog.class).error("Error probably related to bug in JRE occured", npe);
LoginDialog.this.dispose();
}
}
});
} catch (final InvalidVersionException e) {
handleError("You are running an incompatible version of Stendhal. Please update",
"Invalid version");
} catch (final TimeoutException e) {
handleError("Server is not available right now.\nThe server may be down or, if you are using a custom server,\nyou may have entered its name and port number incorrectly.",
"Error Logging In");
} catch (final LoginFailedException e) {
handleError(e.getMessage(), "Login failed");
if (e.getReason() == MessageS2CLoginNACK.Reasons.SEED_WRONG) {
System.exit(1);
}
} catch (final BannedAddressException e) {
handleError("Your IP is banned. If you think this is not right, please send a Support Request to http://sourceforge.net/tracker/?func=add&group_id=1111&atid=201111",
"IP Banned");
}
}
/**
* Displays the error message, removes the progress bar and
* either enabled the login dialog in interactive mode or exits
* the client in non interactive mode.
*
* @param errorMessage error message
* @param errorTitle title of error dialog box
*/
private void handleError(final String errorMessage, final String errorTitle) {
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
progressBar.cancel();
JOptionPane.showMessageDialog(
LoginDialog.this, errorMessage, errorTitle, JOptionPane.ERROR_MESSAGE);
if (isVisible()) {
setEnabled(true);
} else {
// Hack for non interactive login
System.exit(1);
}
}
});
}
/**
* Load saves profiles.
* @return ProfileList
*/
private ProfileList loadProfiles() {
final ProfileList tmpProfiles = new ProfileList();
try {
final InputStream is = Persistence.get().getInputStream(false, stendhal.getGameFolder(),
"user.dat");
try {
tmpProfiles.load(is);
} finally {
is.close();
}
} catch (final FileNotFoundException fnfe) {
// Ignore
} catch (final IOException ioex) {
JOptionPane.showMessageDialog(this,
"An error occurred while loading your login information",
"Error Loading Login Information",
JOptionPane.WARNING_MESSAGE);
}
return tmpProfiles;
}
/**
* Populate the profiles combobox and select the default.
*
* @param profiles profile data
*/
private void populateProfiles(final ProfileList profiles) {
profilesComboBox.removeAllItems();
for (Profile p : profiles) {
profilesComboBox.addItem(p);
}
/*
* The last profile (if any) is the default.
*/
final int count = profilesComboBox.getItemCount();
if (count != 0) {
profilesComboBox.setSelectedIndex(count - 1);
}
}
/**
* Called when a profile selection is changed.
*/
private void profilesCB() {
Profile profile;
String host;
profile = (Profile) profilesComboBox.getSelectedItem();
if (profile != null) {
host = profile.getHost();
serverField.setText(host);
serverPortField.setText(String.valueOf(profile.getPort()));
usernameField.setText(profile.getUser());
passwordField.setText(profile.getPassword());
} else {
serverPortField.setText(String.valueOf(Profile.DEFAULT_SERVER_PORT));
usernameField.setText("");
passwordField.setText("");
}
}
/**
* Checks that a group of Documents (text fields) is not empty, and enables
* or disables a JComponent on that condition.
*/
private static class DataValidator implements DocumentListener {
private final Document[] documents;
private final JComponent component;
/**
* Create a new DataValidator.
*
* @param component component to be enabled depending on the state of
* documents
* @param docs documents
*/
DataValidator(JComponent component, Document... docs) {
this.component = component;
documents = docs;
for (Document doc : docs) {
doc.addDocumentListener(this);
}
revalidate();
}
@Override
public void insertUpdate(DocumentEvent e) {
revalidate();
}
@Override
public void removeUpdate(DocumentEvent e) {
if (e.getDocument().getLength() == 0) {
component.setEnabled(false);
}
}
@Override
public void changedUpdate(DocumentEvent e) {
// Attribute change - ignore
}
/**
* Do a full document state check and set the component status according
* to the result.
*/
final void revalidate() {
for (Document doc : documents) {
if (doc.getLength() == 0) {
component.setEnabled(false);
return;
}
}
component.setEnabled(true);
}
}
/*
* Author: Da_MusH Description: Methods for saving and loading login
* information to disk. These should probably make a separate class in the
* future, but it will work for now. comment: Thegeneral has added encoding
* for password and username. Changed for multiple profiles.
*/
private void saveProfiles(final ProfileList profiles) {
try {
final OutputStream os = Persistence.get().getOutputStream(false,
stendhal.getGameFolder(), "user.dat");
try {
profiles.save(os);
} finally {
os.close();
}
} catch (final IOException ioex) {
JOptionPane.showMessageDialog(this,
"An error occurred while saving your login information",
"Error Saving Login Information",
JOptionPane.WARNING_MESSAGE);
}
}
/**
* Called when save profile selection change.
*/
private void saveProfileStateCB() {
savePasswordBox.setEnabled(saveLoginBox.isSelected());
}
/**
* Server connect thread runnable.
*/
private final class ConnectRunnable implements Runnable {
private final Profile profile;
/**
* Create a new ConnectRunnable.
*
* @param profile profile used for connection
*/
private ConnectRunnable(final Profile profile) {
this.profile = profile;
}
@Override
public void run() {
connect(profile);
}
}
/**
* Profiles combobox selection change listener.
*/
private class ProfilesCB implements ActionListener {
@Override
public void actionPerformed(final ActionEvent e) {
profilesCB();
}
}
/**
* Save profile selection change.
*/
private class SaveProfileStateCB implements ChangeListener {
@Override
public void stateChanged(final ChangeEvent ev) {
saveProfileStateCB();
}
}
}
| dkfellows/stendhal | src/games/stendhal/client/gui/login/LoginDialog.java | Java | gpl-2.0 | 19,502 | [
30522,
1013,
1008,
1002,
8909,
1002,
1008,
1013,
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,
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... |
---
layout: post
title: 'Image optimization: Lossy, lossless and other techniques'
date: 2013-01-04 21:44:57+00:00
tags:
- images
- optimization
- responsive
permalink: image-optimization-lossy-lossless-techniques
---
During last days I have come across interesting articles about images optimization. Images are currently the largest average payload in web sites, meaning a [62%](http://httparchive.org/interesting.php) of all the bytes. With the increasingly importance of responsive design, [responsive images](http://css-tricks.com/which-responsive-images-solution-should-you-use/) are becoming a challenge to face.
I have already talked about image optimization in my [list of optimization techniques](/techniques-optimize-web-sites/#images-optimization) and my short [post about using jpegoptim](/jpegoptim-optimize-jpg-page-speed/). But recently I have read about highly compressed JPG to target high-res screens and progressive JPG images, and I thought it would worth sharing.
<!-- more -->
## Highly compressed JPG images and high resolution screens
[Compressive Images](https://www.filamentgroup.com/lab/compressive-images.html) is a post by Filament Group where they show a way to target responsive images. Instead of using multiple copies of an image with different sizes, you can generate a large JPG image with a compression of 0 quality. That way, not only one single copy can be used to target different screen sizes and resolutions, but there are even large savings in file size comparing to normal 1:1 images.
I have prepared [a demo of the Compressive Images technique](/demos/compressive-images/) where you can test your own images.
<div class="callout">
<strong>Info</strong>: Note that this technique might have a high impact on decoding + resizing, especially on mobile. Tim Kadlec explained it at Velocity SC 2015 in his <a href="https://www.youtube.com/watch?v=jP68rCjSSjM&t=10m56s">Mobile Image Processing talk</a>.
</div>
## Progressive JPEGs
Thanks to [Progressive jpegs: a new best practice](http://calendar.perfplanet.com/2012/progressive-jpegs-a-new-best-practice/) I have learnt that progressive JPGs normally weight less than baseline ones. Not only that, but they make some browsers start rendering the image sooner, preventing showing a white chunk until the full image is downloaded. By using tools such as imageoptim, which runs jpegtran behind the scenes, you can make sure the smallest file is chosen.
That post also links to [Optimizing Images](http://www.bookofspeed.com/chapter5.html), a chapter from Stoyan Stefanov's [Book of Speed](http://www.bookofspeed.com/). In that chapter, Stoyan compiles the main tools to achieve lossless compression of JPG, PNG and GIF images.
If you want to see progressive images in action, check [this demo](http://www.patrickmeenan.com/progressive/view.php?img=http%3A%2F%2Fi2.cdn.turner.com%2Fcnn%2Fdam%2Fassets%2F121205093053-leweb-cyborg-c1-main.jpg) made by [@patmeenan](https://twitter.com/patmeenan) that showing how a JPG is rendered in progressive and baseline mode, and the resulting image of every scan. You can even try with your own image.
## Lossy techniques
To end with, in [Giving Your Images An Extra Squeeze](http://calendar.perfplanet.com/2012/giving-your-images-an-extra-squeeze/) you can see how lossy compression tools can help go the extra mile and reduce even more the size of your images, while keeping quality. It is a nice read about tools such as pngquant and imgmin, as well as the WebP format.
## More resources
If you are interested in image optimization, I recommend you to have a look at [Image Optimization Tools](http://addyosmani.com/blog/image-optimization-tools/), an article by Addy Osmani.
| JMPerez/jmperez.github.com | source/_posts/2013/2013-01-04-image-optimization-lossy-lossless-techniques.md | Markdown | mit | 3,725 | [
30522,
1011,
1011,
1011,
9621,
1024,
2695,
2516,
1024,
1005,
3746,
20600,
1024,
3279,
2100,
1010,
3279,
3238,
1998,
2060,
5461,
1005,
3058,
1024,
2286,
1011,
5890,
1011,
5840,
2538,
1024,
4008,
1024,
5401,
1009,
4002,
1024,
4002,
22073,
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... |
import React from 'react';
import { ViewProps } from '../primitives/View';
export declare const HR: React.ComponentType<ViewProps>;
| exponent/exponent | packages/html-elements/build/elements/Rules.d.ts | TypeScript | bsd-3-clause | 132 | [
30522,
12324,
10509,
2013,
1005,
10509,
1005,
1025,
12324,
1063,
3193,
21572,
4523,
1065,
2013,
1005,
1012,
1012,
1013,
10968,
2015,
1013,
3193,
1005,
1025,
9167,
13520,
9530,
3367,
17850,
1024,
10509,
1012,
6922,
13874,
1026,
3193,
21572,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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.
*/
#ifndef CBOR_CNT_WRITER_H
#define CBOR_CNT_WRITER_H
#include "cbor.h"
#ifdef __cplusplus
extern "C" {
#endif
/* use this count writer if you want to try out a cbor encoding to see
* how long it would be (before allocating memory). This replaced the
* code in tinycbor.h that would try to do this once the encoding failed
* in a buffer. Its much easier to understand this way (for me)
*/
struct CborCntWriter {
struct cbor_encoder_writer enc;
};
static inline int
cbor_cnt_writer(struct cbor_encoder_writer *arg, const char *data, int len) {
struct CborCntWriter *cb = (struct CborCntWriter *) arg;
cb->enc.bytes_written += len;
return CborNoError;
}
static inline void
cbor_cnt_writer_init(struct CborCntWriter *cb) {
cb->enc.bytes_written = 0;
cb->enc.write = &cbor_cnt_writer;
}
#ifdef __cplusplus
}
#endif
#endif /* CBOR_CNT_WRITER_H */
| andrzej-kaczmarek/incubator-mynewt-core | encoding/tinycbor/include/tinycbor/cbor_cnt_writer.h | C | apache-2.0 | 1,707 | [
30522,
1013,
1008,
1008,
7000,
2000,
1996,
15895,
4007,
3192,
1006,
2004,
2546,
1007,
2104,
2028,
1008,
2030,
2062,
12130,
6105,
10540,
1012,
2156,
1996,
5060,
5371,
1008,
5500,
2007,
2023,
2147,
2005,
3176,
2592,
1008,
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... |
// Copyright 2016-2022 The Libsacloud Authors
//
// 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 main
import (
"log"
"path/filepath"
"github.com/sacloud/libsacloud/v2/internal/define"
"github.com/sacloud/libsacloud/v2/internal/tools"
)
const destination = "sacloud/zz_api_ops.go"
func init() {
log.SetFlags(0)
log.SetPrefix("gen-api-op: ")
}
func main() {
outputPath := destination
tools.WriteFileWithTemplate(&tools.TemplateConfig{
OutputPath: filepath.Join(tools.ProjectRootPath(), outputPath),
Template: tmpl,
Parameter: define.APIs,
})
log.Printf("generated: %s\n", outputPath)
}
const tmpl = `// generated by 'github.com/sacloud/libsacloud/internal/tools/gen-api-op'; DO NOT EDIT
package sacloud
import (
"context"
"github.com/sacloud/libsacloud/v2/pkg/mutexkv"
"github.com/sacloud/libsacloud/v2/sacloud/types"
)
var apiLocker = mutexkv.NewMutexKV()
func init() {
{{ range . }}
SetClientFactoryFunc("{{.TypeName}}", func(caller APICaller) interface{} {
return &{{ .TypeName }}Op {
Client: caller,
PathSuffix: "{{.GetPathSuffix}}",
PathName: "{{.GetPathName}}",
}
})
{{ end -}}
}
{{ range . }}{{ $typeName := .TypeName }}{{$resource := .}}
/*************************************************
* {{$typeName}}Op
*************************************************/
// {{ .TypeName }}Op implements {{ .TypeName }}API interface
type {{ .TypeName }}Op struct{
// Client APICaller
Client APICaller
// PathSuffix is used when building URL
PathSuffix string
// PathName is used when building URL
PathName string
}
// New{{ $typeName}}Op creates new {{ $typeName}}Op instance
func New{{ $typeName}}Op(caller APICaller) {{ $typeName}}API {
return GetClientFactoryFunc("{{$typeName}}")(caller).({{$typeName}}API)
}
{{ range .Operations }}{{$returnErrStatement := .ReturnErrorStatement}}{{ $operationName := .MethodName }}
// {{ .MethodName }} is API call
func (o *{{ $typeName }}Op) {{ .MethodName }}(ctx context.Context{{if not $resource.IsGlobal}}, zone string{{end}}{{ range .Arguments }}, {{ .ArgName }} {{ .TypeName }}{{ end }}) {{.ResultsStatement}} {
// build request URL
pathBuildParameter := map[string]interface{}{
"rootURL": SakuraCloudAPIRoot,
"pathSuffix": o.PathSuffix,
"pathName": o.PathName,
{{- if $resource.IsGlobal }}
"zone": APIDefaultZone,
{{- else }}
"zone": zone,
{{- end }}
{{- range .Arguments }}
"{{.PathFormatName}}": {{.Name}},
{{- end }}
}
url, err := buildURL("{{.GetPathFormat}}", pathBuildParameter)
if err != nil {
return {{ $returnErrStatement }}
}
{{ if .LockKeyFormat -}}
lockKey, err := buildURL("{{.LockKeyFormat}}", pathBuildParameter)
if err != nil {
return {{ $returnErrStatement }}
}
apiLocker.Lock(lockKey)
defer apiLocker.Unlock(lockKey)
{{ end -}}
// build request body
var body interface{}
{{ if .HasRequestEnvelope -}}
v, err := o.transform{{.MethodName}}Args({{ range .Arguments }}{{ .ArgName }},{{ end }})
if err != nil {
return {{ $returnErrStatement }}
}
body = v
{{ end }}
// do request
{{ if .HasResponseEnvelope -}}
data, err := o.Client.Do(ctx, "{{.Method}}", url, body)
{{ else -}}
_, err = o.Client.Do(ctx, "{{.Method}}", url, body)
{{ end -}}
if err != nil {
return {{ $returnErrStatement }}
}
// build results
{{ if .HasResponseEnvelope -}}
results, err := o.transform{{.MethodName}}Results(data)
if err != nil {
return {{ $returnErrStatement }}
}
return {{ .ReturnStatement }}
{{ else }}
return nil
{{ end -}}
}
{{ end -}}
{{ end -}}
`
| sacloud/libsacloud | v2/internal/tools/gen-api-op/main.go | GO | apache-2.0 | 4,040 | [
30522,
1013,
1013,
9385,
2355,
1011,
16798,
2475,
1996,
5622,
5910,
6305,
23743,
2094,
6048,
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
namespace MusicBrainz\Relation\Type\Artist\Recording;
use MusicBrainz\Relation\Type\Artist\Recording;
use MusicBrainz\Value\Name;
/**
* This relationship type is only used for grouping other relationship types.
*
* @link https://musicbrainz.org/relationship/b367fae0-c4b0-48b9-a40c-f3ae4c02cffc
*/
abstract class Production extends Recording
{
/**
* Returns the name of the relation.
*
* @return Name
*/
public static function getRelationName(): Name
{
return new Name('production');
}
}
| XenosEleatikos/MusicBrainz | src/Relation/Type/Artist/Recording/Production.php | PHP | mit | 545 | [
30522,
1026,
1029,
25718,
3415,
15327,
2189,
10024,
2378,
2480,
1032,
7189,
1032,
2828,
1032,
3063,
1032,
3405,
1025,
2224,
2189,
10024,
2378,
2480,
1032,
7189,
1032,
2828,
1032,
3063,
1032,
3405,
1025,
2224,
2189,
10024,
2378,
2480,
1032,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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: "Community Update 2014-02-10 – #rest API versioning, building a file server with #owin, #helios and ElasticSearch with #D3js"
date: 2014-02-10 14:38:26
tags: [community update]
---
It looks like today is the day of ASP.NET, OWIN and REST API versioning.
Among those, I would recommend checking out the video by Damian Edwards (one of the guy that works on SignalR) about what NOT to do. If you don’t have the time, at least read the article by Scott Hanselman.
As an additional bonus, a simple post about data visualization with nothing else than ElasticSearch and D3.
Enjoy!
### Owin & Katana
* [Building A Simple File Server With OWIN and Katana (odetocode.com)](http://odetocode.com/blogs/scott/archive/2014/02/10/building-a-simple-file-server-with-owin-and-katana.aspx)
### REST and API Versioning
* [Troy Hunt: Your API versioning is wrong, which is why I decided to do it 3 different wrong ways (www.troyhunt.com)](http://www.troyhunt.com/2014/02/your-api-versioning-is-wrong-which-is.html)
* [rest - Best practices for API versioning? - Stack Overflow (stackoverflow.com)](http://stackoverflow.com/questions/389169/best-practices-for-api-versioning)
### ASP.NET
* [Khalid Abuhakmeh - ASP.NET MVC 5 Authentication Breakdown : Part Deux (www.khalidabuhakmeh.com)](http://www.khalidabuhakmeh.com/asp-net-mvc-5-authentication-breakdown-part-deux)
* [How MembershipReboot stores passwords properly | brockallen on WordPress.com (brockallen.com)](http://brockallen.com/2014/02/09/how-membershipreboot-stores-passwords-properly/)
* [Checking out the Helios IIS Owin Web Server Host - Rick Strahl's Web Log (weblog.west-wind.com)](http://weblog.west-wind.com/posts/2013/Nov/23/Checking-out-the-Helios-IIS-Owin-Web-Server-Host)
* [Damian Edwards: Don’t do that, do this! Recommendations from the ASP.NET team on Vimeo (vimeo.com)](http://vimeo.com/68390507) – This is a video, it is worth watching.
* [Checklist: What NOT to do in ASP.NET - Scott Hanselman (www.hanselman.com)](http://www.hanselman.com/blog/ChecklistWhatNOTToDoInASPNET.aspx)
### ElasticSearch
* [Data Visualization With Elasticsearch Aggregations And D3 | Blog | Elasticsearch (www.elasticsearch.org)](http://www.elasticsearch.org/blog/data-visualization-elasticsearch-aggregations/) – Only ElasticSearch and Javascript!
| MaximRouiller/blog.decayingcode.com | source/_posts/Community-Update-2014-02-10-rest-API-versioning-building-a-file-server-with-owin-helios-and-ElasticSearch-with-D3js.md | Markdown | cc0-1.0 | 2,346 | [
30522,
1011,
1011,
1011,
2516,
1024,
1000,
2451,
10651,
2297,
1011,
6185,
1011,
2184,
1516,
1001,
2717,
17928,
2544,
2075,
1010,
2311,
1037,
5371,
8241,
2007,
1001,
27593,
2378,
1010,
1001,
2002,
12798,
2015,
1998,
21274,
17310,
11140,
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... |
#ifndef DATTO_CLIENT_DEVICE_SYNCHRONIZER_DEVICE_SYNCHRONIZER_INTERFACE_H_
#define DATTO_CLIENT_DEVICE_SYNCHRONIZER_DEVICE_SYNCHRONIZER_INTERFACE_H_
#include <memory>
#include "backup/backup_coordinator.h"
#include "backup_status_tracker/sync_count_handler.h"
#include "block_device/block_device.h"
#include "block_device/mountable_block_device.h"
#include "unsynced_sector_manager/unsynced_sector_manager.h"
namespace datto_linux_client {
// Existance of this class allows for easier mocking in unit tests
// The real work is done in DeviceSynchronizer
class DeviceSynchronizerInterface {
public:
// Precondition: source_device must be both traced and mounted
virtual void DoSync(std::shared_ptr<BackupCoordinator> coordinator,
std::shared_ptr<SyncCountHandler> count_handler) = 0;
virtual std::shared_ptr<const MountableBlockDevice>
source_device() const = 0;
virtual std::shared_ptr<const UnsyncedSectorManager>
sector_manager() const = 0;
virtual std::shared_ptr<const BlockDevice> destination_device() const = 0;
virtual ~DeviceSynchronizerInterface() {}
DeviceSynchronizerInterface(const DeviceSynchronizerInterface &) = delete;
DeviceSynchronizerInterface&
operator=(const DeviceSynchronizerInterface &) = delete;
protected:
DeviceSynchronizerInterface() {}
};
}
#endif // DATTO_CLIENT_DEVICE_SYNCHRONIZER_DEVICE_SYNCHRONIZER_INTERFACE_H_
| fuhry/linux-agent | device_synchronizer/device_synchronizer_interface.h | C | gpl-2.0 | 1,404 | [
30522,
1001,
2065,
13629,
2546,
23755,
3406,
1035,
7396,
1035,
5080,
1035,
26351,
8093,
10698,
6290,
1035,
5080,
1035,
26351,
8093,
10698,
6290,
1035,
8278,
1035,
1044,
1035,
1001,
9375,
23755,
3406,
1035,
7396,
1035,
5080,
1035,
26351,
809... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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 FoodCoopBundle\Actions;
use FoodCoopBundle\Entity\Order;
use Codifico\Component\Actions\Action\Basic\RemoveAction;
use FoodCoopBundle\Event\EntityRemoveEvent;
use Codifico\Component\Actions\Repository\ActionRepository;
use Psr\Log\LoggerInterface;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
class OrderRemoveAction extends RemoveAction
{
/**
* @var EventDispatcherInterface
*/
private $dispatcher;
/**
* @var LoggerInterface
*/
private $logger;
public function __construct(EventDispatcherInterface $dispatcher, ActionRepository $repository, LoggerInterface $logger)
{
$this->dispatcher = $dispatcher;
$this->logger = $logger;
parent::__construct($repository);
}
/**
* @param $object
* @return void
*/
public function postRemove($object)
{
$this->dispatcher->dispatch('action.remove', new EntityRemoveEvent($object));
}
/**
* @param Order $order
* @return OrderRemoveAction
*/
public function setOrder(Order $order)
{
parent::setObject($order);
return $this;
}
/**
* Creates new entity
*
* @return mixed
*/
public function execute()
{
if ($this->object->isActive()) {
throw new \LogicException('Order is active');
}
if ($this->object->hasItems()) {
throw new \LogicException('Order has items');
}
$message = 'Deleting order: '. $this->object->getExecutionAt()->format('Y-m-d').'.';
foreach ($this->object->getItems() as $item) {
$message .= ' Item: User.id='.$item->getOwner()->getId()
.' Product.id='.$item->getProduct()->getId().' quantity='.$item->getQuantity().'.';
}
$this->logger->info($message);
parent::execute();
$this->postRemove($this->object);
}
}
| FoodCoopSystem/fcs-backend | src/FoodCoopBundle/Actions/OrderRemoveAction.php | PHP | mit | 1,936 | [
30522,
1026,
1029,
25718,
3415,
15327,
2833,
3597,
7361,
27265,
2571,
1032,
4506,
1025,
2224,
2833,
3597,
7361,
27265,
2571,
1032,
9178,
1032,
2344,
1025,
2224,
19429,
18513,
2080,
1032,
6922,
1032,
4506,
1032,
2895,
1032,
3937,
1032,
6366,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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/PA-RISC Project (http://www.parisc-linux.org/)
*
* Floating-point emulation code
* Copyright (C) 2001 Hewlett-Packard (Paul Bame) <bame@debian.org>
*
* 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, 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., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/*
* BEGIN_DESC
*
* File:
* @(#) pa/spmath/sfcmp.c $Revision: 1.1.1.1 $
*
* Purpose:
* sgl_cmp: compare two values
*
* External Interfaces:
* sgl_fcmp(leftptr, rightptr, cond, status)
*
* Internal Interfaces:
*
* Theory:
* <<please update with a overview of the operation of this file>>
*
* END_DESC
*/
#include "float.h"
#include "sgl_float.h"
/*
* sgl_cmp: compare two values
*/
int
sgl_fcmp (sgl_floating_point * leftptr, sgl_floating_point * rightptr,
unsigned int cond, unsigned int *status)
/* The predicate to be tested */
{
register unsigned int left, right;
register int xorresult;
/* Create local copies of the numbers */
left = *leftptr;
right = *rightptr;
/*
* Test for NaN
*/
if( (Sgl_exponent(left) == SGL_INFINITY_EXPONENT)
|| (Sgl_exponent(right) == SGL_INFINITY_EXPONENT) )
{
/* Check if a NaN is involved. Signal an invalid exception when
* comparing a signaling NaN or when comparing quiet NaNs and the
* low bit of the condition is set */
if( ( (Sgl_exponent(left) == SGL_INFINITY_EXPONENT)
&& Sgl_isnotzero_mantissa(left)
&& (Exception(cond) || Sgl_isone_signaling(left)))
||
( (Sgl_exponent(right) == SGL_INFINITY_EXPONENT)
&& Sgl_isnotzero_mantissa(right)
&& (Exception(cond) || Sgl_isone_signaling(right)) ) )
{
if( Is_invalidtrap_enabled() ) {
Set_status_cbit(Unordered(cond));
return(INVALIDEXCEPTION);
}
else Set_invalidflag();
Set_status_cbit(Unordered(cond));
return(NOEXCEPTION);
}
/* All the exceptional conditions are handled, now special case
NaN compares */
else if( ((Sgl_exponent(left) == SGL_INFINITY_EXPONENT)
&& Sgl_isnotzero_mantissa(left))
||
((Sgl_exponent(right) == SGL_INFINITY_EXPONENT)
&& Sgl_isnotzero_mantissa(right)) )
{
/* NaNs always compare unordered. */
Set_status_cbit(Unordered(cond));
return(NOEXCEPTION);
}
/* infinities will drop down to the normal compare mechanisms */
}
/* First compare for unequal signs => less or greater or
* special equal case */
Sgl_xortointp1(left,right,xorresult);
if( xorresult < 0 )
{
/* left negative => less, left positive => greater.
* equal is possible if both operands are zeros. */
if( Sgl_iszero_exponentmantissa(left)
&& Sgl_iszero_exponentmantissa(right) )
{
Set_status_cbit(Equal(cond));
}
else if( Sgl_isone_sign(left) )
{
Set_status_cbit(Lessthan(cond));
}
else
{
Set_status_cbit(Greaterthan(cond));
}
}
/* Signs are the same. Treat negative numbers separately
* from the positives because of the reversed sense. */
else if( Sgl_all(left) == Sgl_all(right) )
{
Set_status_cbit(Equal(cond));
}
else if( Sgl_iszero_sign(left) )
{
/* Positive compare */
if( Sgl_all(left) < Sgl_all(right) )
{
Set_status_cbit(Lessthan(cond));
}
else
{
Set_status_cbit(Greaterthan(cond));
}
}
else
{
/* Negative compare. Signed or unsigned compares
* both work the same. That distinction is only
* important when the sign bits differ. */
if( Sgl_all(left) > Sgl_all(right) )
{
Set_status_cbit(Lessthan(cond));
}
else
{
Set_status_cbit(Greaterthan(cond));
}
}
return(NOEXCEPTION);
}
| nslu2/linux-2.4.x | arch/parisc/math-emu/sfcmp.c | C | gpl-2.0 | 4,502 | [
30522,
1013,
1008,
1008,
11603,
1013,
6643,
1011,
15544,
11020,
2622,
1006,
8299,
1024,
1013,
1013,
7479,
1012,
3000,
2278,
1011,
11603,
1012,
8917,
1013,
1007,
1008,
1008,
8274,
1011,
2391,
7861,
9513,
3642,
1008,
9385,
1006,
1039,
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... |
let obj = {
@readonly firstName: "first",
@readonly lastName: "last",
@nonconfigurable fullName() {
return `${this.firstName} ${this.lastName}`;
}
};
/*
// Desugaring
//
// The following is an approximate down-level desugaring to match the expected semantics.
// The actual host implementation would generally be more efficient.
let obj = declareObject(
// Object literal declaration
{
firstName: "first",
lastName: "last",
fullName() {
return `${this.firstName} ${this.lastName}`;
}
},
// Object description
{
members: [
{ kind: "property", name: "firstName", decorations: [readonly] },
{ kind: "property", name: "lastName", decorations: [readonly] },
{ kind: "method", name: "fullName", decorations: [nonconfigurable] }
]
}
).finishDeclarationInitialization();
*/ | rbuckton/ecmascript-mirrors | samples/objects.js | JavaScript | apache-2.0 | 945 | [
30522,
2292,
27885,
3501,
1027,
1063,
1030,
3191,
2239,
2135,
2034,
18442,
1024,
1000,
2034,
1000,
1010,
1030,
3191,
2239,
2135,
2197,
18442,
1024,
1000,
2197,
1000,
1010,
1030,
2512,
8663,
8873,
27390,
3085,
2440,
18442,
1006,
1007,
1063,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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
/*=========================================================================
MIDAS Server
Copyright (c) Kitware SAS. 20 rue de la Villette. All rights reserved.
69328 Lyon, FRANCE.
See Copyright.txt for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notices for more information.
=========================================================================*/
/** Assetstore Model Base*/
abstract class AssetstoreModelBase extends AppModel
{
/** Constructor*/
public function __construct()
{
parent::__construct();
$this->_name = 'assetstore';
$this->_key = 'assetstore_id';
$this->_mainData = array(
'assetstore_id' => array('type' => MIDAS_DATA),
'name' => array('type' => MIDAS_DATA),
'itemrevision_id' => array('type' => MIDAS_DATA),
'path' => array('type' => MIDAS_DATA),
'type' => array('type' => MIDAS_DATA),
'bitstreams' => array('type' => MIDAS_ONE_TO_MANY, 'model' => 'Bitstream', 'parent_column' => 'assetstore_id', 'child_column' => 'assetstore_id'),
);
$this->initialize(); // required
} // end __construct()
/** Abstract functions */
abstract function getAll();
/** save an assetsore*/
public function save($dao)
{
parent::save($dao);
}
/** delete an assetstore (and all the items in it)*/
public function delete($dao)
{
if(!$dao instanceof AssetstoreDao)
{
throw new Zend_Exception("Error param.");
}
$bitreams = $dao->getBitstreams();
$items = array();
foreach($bitreams as $key => $bitstream)
{
$revision = $bitstream->getItemrevision();
if(empty($revision))
{
continue;
}
$item = $revision->getItem();
if(empty($item))
{
continue;
}
$items[$item->getKey()] = $item;
}
$modelLoader = new MIDAS_ModelLoader();
$item_model = $modelLoader->loadModel('Item');
foreach($items as $item)
{
$item_model->delete($item);
}
parent::delete($dao);
}// delete
} // end class AssetstoreModelBase | mgrauer/midas3score | core/models/base/AssetstoreModelBase.php | PHP | bsd-3-clause | 2,220 | [
30522,
1026,
1029,
25718,
1013,
1008,
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,
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... |
using System;
using Xamarin.Forms;
using System.Collections.ObjectModel;
using LinqToTwitter;
using System.Threading.Tasks;
using System.Linq;
namespace Hanselman.Portable
{
public class TwitterViewModel : BaseViewModel
{
public ObservableCollection<Tweet> Tweets { get; set; }
public TwitterViewModel()
{
Title = "Twitter";
Icon = "slideout.png";
Tweets = new ObservableCollection<Tweet>();
}
private Command loadTweetsCommand;
public Command LoadTweetsCommand
{
get
{
return loadTweetsCommand ??
(loadTweetsCommand = new Command(async () =>
{
await ExecuteLoadTweetsCommand();
}, () =>
{
return !IsBusy;
}));
}
}
public async Task ExecuteLoadTweetsCommand()
{
if (IsBusy)
return;
IsBusy = true;
LoadTweetsCommand.ChangeCanExecute();
var error = false;
try
{
Tweets.Clear();
var auth = new ApplicationOnlyAuthorizer()
{
CredentialStore = new InMemoryCredentialStore
{
ConsumerKey = "ZTmEODUCChOhLXO4lnUCEbH2I",
ConsumerSecret = "Y8z2Wouc5ckFb1a0wjUDT9KAI6DUat5tFNdmIkPLl8T4Nyaa2J",
},
};
await auth.AuthorizeAsync();
var twitterContext = new TwitterContext(auth);
var queryResponse = await
(from tweet in twitterContext.Status
where tweet.Type == StatusType.User &&
tweet.ScreenName == "shanselman" &&
tweet.Count == 100 &&
tweet.IncludeRetweets == true &&
tweet.ExcludeReplies == true
select tweet).ToListAsync();
var tweets =
(from tweet in queryResponse
select new Tweet
{
StatusID = tweet.StatusID,
ScreenName = tweet.User.ScreenNameResponse,
Text = tweet.Text,
CurrentUserRetweet = tweet.CurrentUserRetweet,
CreatedAt = tweet.CreatedAt,
Image = tweet.RetweetedStatus != null && tweet.RetweetedStatus.User != null ?
tweet.RetweetedStatus.User.ProfileImageUrl.Replace("http://", "https://") : (tweet.User.ScreenNameResponse == "shanselman" ? "scott159.png" : tweet.User.ProfileImageUrl.Replace("http://", "https://"))
}).ToList();
foreach (var tweet in tweets)
{
Tweets.Add(tweet);
}
if (Device.OS == TargetPlatform.iOS)
{
// only does anything on iOS, for the Watch
DependencyService.Get<ITweetStore>().Save(tweets);
}
}
catch
{
error = true;
}
if (error)
{
var page = new ContentPage();
await page.DisplayAlert("Error", "Unable to load tweets.", "OK");
}
IsBusy = false;
LoadTweetsCommand.ChangeCanExecute();
}
}
}
| Oriphim/mtgscotland | Hanselman.Portable/ViewModels/TwitterViewModel.cs | C# | mit | 3,592 | [
30522,
2478,
2291,
1025,
2478,
1060,
8067,
6657,
1012,
3596,
1025,
2478,
2291,
1012,
6407,
1012,
4874,
5302,
9247,
1025,
2478,
11409,
4160,
3406,
2102,
9148,
12079,
1025,
2478,
2291,
1012,
11689,
2075,
1012,
8518,
1025,
2478,
2291,
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... |
using Newtonsoft.Json;
using NZgeek.ElitePlayerJournal.Events.Types;
namespace NZgeek.ElitePlayerJournal.Events.Startup
{
public class LoadGame : Event
{
[JsonProperty("Commander")]
public string CommanderName { get; private set; }
[JsonProperty("Ship")]
public string ShipType { get; private set; }
[JsonProperty("ShipID")]
public int ShipId { get; private set; }
[JsonProperty("ShipName")]
public string ShipName { get; private set; }
[JsonProperty("ShipIdent")]
public string ShipIdent { get; private set; }
[JsonProperty("GameMode")]
public GameMode GameMode { get; private set; }
[JsonProperty("StartDead")]
public bool StartAtRebuy { get; private set; }
[JsonProperty("StartLanded")]
public bool StartLanded { get; private set; }
[JsonProperty("Group")]
public string PrivateGroupName { get; private set; }
[JsonProperty("Credits")]
public decimal Credits { get; private set; }
[JsonProperty("Loan")]
public decimal Loan { get; private set; }
[JsonProperty("FuelLevel")]
public decimal FuelLevel { get; private set; }
[JsonProperty("FuelCapacity")]
public decimal FuelCapacity { get; private set; }
public override string ToString() => $"{base.ToString()} => {CommanderName} ({ShipType} #{ShipId}) {Credits:#,##0} cr";
}
}
| nzgeek/ElitePlayerJournal | src/Events/Startup/LoadGame.cs | C# | mit | 1,474 | [
30522,
2478,
8446,
6499,
6199,
1012,
1046,
3385,
1025,
2478,
20008,
18372,
2243,
1012,
7069,
13068,
2121,
23099,
12789,
2140,
1012,
2824,
1012,
4127,
1025,
3415,
15327,
20008,
18372,
2243,
1012,
7069,
13068,
2121,
23099,
12789,
2140,
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... |
<div class="row">
<?php
if ( have_posts() ) : while ( have_posts() ) : the_post();
/**
* Get blog posts by blog layout.
*/
get_template_part('loop/content', 'team-full');
endwhile;
else :
/**
* Display no posts message if none are found.
*/
get_template_part('loop/content','none');
endif;
?>
</div> | seyekuyinu/highlifer | wp-content/themes/highlifer/loop/loop-team-full.php | PHP | gpl-2.0 | 355 | [
30522,
1026,
4487,
2615,
2465,
1027,
1000,
5216,
1000,
1028,
1026,
1029,
25718,
2065,
1006,
2031,
1035,
8466,
1006,
1007,
1007,
1024,
2096,
1006,
2031,
1035,
8466,
1006,
1007,
1007,
1024,
1996,
1035,
2695,
1006,
1007,
1025,
1013,
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... |
<dom-module id="demo-simple">
<style>
:host {
display: flex;
flex-wrap: nowrap;
align-items: stretch;
flex-direction: column;
}
</style>
<template>
This is a simple panel
</template>
</dom-module>
<script>
Editor.registerPanel( 'demo-simple.panel', {
is: 'demo-simple',
});
</script>
| cuit-zhaxin/editor-framework | test/fixtures/packages/simple/panel/panel.html | HTML | mit | 378 | [
30522,
1026,
14383,
1011,
11336,
8909,
1027,
1000,
9703,
1011,
3722,
1000,
1028,
1026,
2806,
1028,
1024,
3677,
1063,
4653,
1024,
23951,
1025,
23951,
1011,
10236,
1024,
2085,
2527,
2361,
1025,
25705,
1011,
5167,
1024,
7683,
1025,
23951,
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... |
package org.metaborg.spoofax.eclipse.editor;
public interface IEclipseEditorRegistryInternal {
void register();
} | metaborg/spoofax-eclipse | org.metaborg.spoofax.eclipse/src/main/java/org/metaborg/spoofax/eclipse/editor/IEclipseEditorRegistryInternal.java | Java | apache-2.0 | 118 | [
30522,
7427,
8917,
1012,
18804,
11755,
1012,
11867,
21511,
8528,
1012,
13232,
1012,
3559,
1025,
2270,
8278,
24940,
15000,
19763,
23194,
2953,
2890,
24063,
2854,
18447,
11795,
2389,
1063,
11675,
4236,
1006,
1007,
1025,
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... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 the Sputnik authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/**
* @name: S12.10_A1.4_T4;
* @section: 12.10;
* @assertion: The with statement adds a computed object to the front of the
* scope chain of the current execution context;
* @description: Using "with" statement within iteration statement, leading to completion by break;
* @strict_mode_negative
*/
this.p1 = 1;
this.p2 = 2;
this.p3 = 3;
var result = "result";
var myObj = {p1: 'a',
p2: 'b',
p3: 'c',
value: 'myObj_value',
valueOf : function(){return 'obj_valueOf';},
parseInt : function(){return 'obj_parseInt';},
NaN : 'obj_NaN',
Infinity : 'obj_Infinity',
eval : function(){return 'obj_eval';},
parseFloat : function(){return 'obj_parseFloat';},
isNaN : function(){return 'obj_isNaN';},
isFinite : function(){return 'obj_isFinite';}
}
var del;
var st_p1 = "p1";
var st_p2 = "p2";
var st_p3 = "p3";
var st_parseInt = "parseInt";
var st_NaN = "NaN";
var st_Infinity = "Infinity";
var st_eval = "eval";
var st_parseFloat = "parseFloat";
var st_isNaN = "isNaN";
var st_isFinite = "isFinite";
do{
with(myObj){
st_p1 = p1;
st_p2 = p2;
st_p3 = p3;
st_parseInt = parseInt;
st_NaN = NaN;
st_Infinity = Infinity;
st_eval = eval;
st_parseFloat = parseFloat;
st_isNaN = isNaN;
st_isFinite = isFinite;
p1 = 'x1';
this.p2 = 'x2';
del = delete p3;
var p4 = 'x4';
p5 = 'x5';
var value = 'value';
break;
}
}
while(false);
if(!(p1 === 1)){
$ERROR('#1: p1 === 1. Actual: p1 ==='+ p1 );
}
if(!(p2 === "x2")){
$ERROR('#2: p2 === "x2". Actual: p2 ==='+ p2 );
}
if(!(p3 === 3)){
$ERROR('#3: p3 === 3. Actual: p3 ==='+ p3 );
}
if(!(p4 === "x4")){
$ERROR('#4: p4 === "x4". Actual: p4 ==='+ p4 );
}
if(!(p5 === "x5")){
$ERROR('#5: p5 === "x5". Actual: p5 ==='+ p5 );
}
if(!(myObj.p1 === "x1")){
$ERROR('#6: myObj.p1 === "x1". Actual: myObj.p1 ==='+ myObj.p1 );
}
if(!(myObj.p2 === "b")){
$ERROR('#7: myObj.p2 === "b". Actual: myObj.p2 ==='+ myObj.p2 );
}
if(!(myObj.p3 === undefined)){
$ERROR('#8: myObj.p3 === undefined. Actual: myObj.p3 ==='+ myObj.p3 );
}
if(!(myObj.p4 === undefined)){
$ERROR('#9: myObj.p4 === undefined. Actual: myObj.p4 ==='+ myObj.p4 );
}
if(!(myObj.p5 === undefined)){
$ERROR('#10: myObj.p5 === undefined. Actual: myObj.p5 ==='+ myObj.p5 );
}
if(!(st_parseInt !== parseInt)){
$ERROR('#11: myObj.parseInt !== parseInt');
}
if(!(st_NaN === "obj_NaN")){
$ERROR('#12: myObj.NaN !== NaN');
}
if(!(st_Infinity !== Infinity)){
$ERROR('#13: myObj.Infinity !== Infinity');
}
if(!(st_eval !== eval)){
$ERROR('#14: myObj.eval !== eval');
}
if(!(st_parseFloat !== parseFloat)){
$ERROR('#15: myObj.parseFloat !== parseFloat');
}
if(!(st_isNaN !== isNaN)){
$ERROR('#16: myObj.isNaN !== isNaN');
}
if(!(st_isFinite !== isFinite)){
$ERROR('#17: myObj.isFinite !== isFinite');
}
if(!(value === undefined)){
$ERROR('#18: value === undefined. Actual: value ==='+ value );
}
if(!(myObj.value === "value")){
$ERROR('#19: myObj.value === "value". Actual: myObj.value ==='+ myObj.value );
}
| rustoscript/js.rs | sputnik/12_Statement/12.10_The_with_Statement/S12.10_A1.4_T4.js | JavaScript | mit | 3,319 | [
30522,
1013,
1013,
9385,
2268,
1996,
11867,
4904,
8238,
6048,
1012,
2035,
2916,
9235,
1012,
1013,
1013,
2023,
3642,
2003,
9950,
2011,
1996,
18667,
2094,
6105,
2179,
1999,
1996,
6105,
5371,
1012,
1013,
1008,
1008,
1008,
1030,
2171,
1024,
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
/**
* Zend Framework
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://framework.zend.com/license/new-bsd
* 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@zend.com so we can send you a copy immediately.
*
* @category Zend
* @package Zend_Gdata
* @subpackage YouTube
* @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/
/**
* @see Zend_Gdata_feed
*/
require_once 'Zend/Gdata/Feed.php';
/**
* @see Zend_Gdata_YouTube_CommentEntry
*/
require_once 'Zend/Gdata/YouTube/CommentEntry.php';
/**
* The YouTube comments flavor of an Atom Feed
*
* @category Zend
* @package Zend_Gdata
* @subpackage YouTube
* @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Gdata_YouTube_CommentFeed extends Zend_Gdata_Feed
{
/**
* The classname for individual feed elements.
*
* @var string
*/
protected $_entryClassName = 'Zend_Gdata_YouTube_CommentEntry';
/**
* Constructs a new YouTube Comment Feed object, to represent
* a feed of comments for an individual video
*
* @param DOMElement $element (optional) DOMElement from which this
* object should be constructed.
*/
public function __construct($element = null)
{
$this->registerAllNamespaces(Zend_Gdata_YouTube::$namespaces);
parent::__construct($element);
}
}
| Harshad-Makwana/NEW-Facebook-Photos-Challenges | libs/Zend/Gdata/YouTube/CommentFeed.php | PHP | apache-2.0 | 1,908 | [
30522,
1026,
1029,
25718,
1013,
1008,
1008,
1008,
16729,
2094,
7705,
1008,
1008,
6105,
1008,
1008,
2023,
3120,
5371,
2003,
3395,
2000,
1996,
2047,
18667,
2094,
6105,
2008,
2003,
24378,
1008,
2007,
2023,
7427,
1999,
1996,
5371,
6105,
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... |
$commandname = $MyInvocation.MyCommand.Name.Replace(".Tests.ps1", "")
Write-Host -Object "Running $PSCommandpath" -ForegroundColor Cyan
. "$PSScriptRoot\constants.ps1"
Describe "$commandname Unit Tests" -Tag "UnitTests" {
$global:object = [PSCustomObject]@{
Foo = 42
Bar = 18
Tara = 21
}
$global:object2 = [PSCustomObject]@{
Foo = 42000
Bar = 23
}
$global:list = @()
$global:list += $object
$global:list += [PSCustomObject]@{
Foo = 23
Bar = 88
Tara = 28
}
It "renames Bar to Bar2" {
($object | Select-DbaObject -Property 'Foo', 'Bar as Bar2').PSObject.Properties.Name | Should -Be 'Foo', 'Bar2'
}
It "changes Bar to string" {
($object | Select-DbaObject -Property 'Bar to string').Bar.GetType().FullName | Should -Be 'System.String'
}
it "converts numbers to sizes" {
($object2 | Select-DbaObject -Property 'Foo size KB:1').Foo | Should -Be 41
($object2 | Select-DbaObject -Property 'Foo size KB:1:1').Foo | Should -Be "41 KB"
}
it "picks values from other variables" {
($object2 | Select-DbaObject -Property 'Tara from object').Tara | Should -Be 21
}
it "picks values from the properties of the right object in a list" {
($object2 | Select-DbaObject -Property 'Tara from List where Foo = Bar').Tara | Should -Be 28
}
} | sqlpadawan/dbatools | tests/Select-DbaObject.Tests.ps1 | PowerShell | mit | 1,452 | [
30522,
1002,
3094,
18442,
1027,
1002,
2026,
2378,
19152,
1012,
2026,
9006,
2386,
2094,
1012,
2171,
1012,
5672,
1006,
1000,
1012,
5852,
1012,
8827,
2487,
1000,
1010,
1000,
1000,
1007,
4339,
1011,
3677,
1011,
4874,
1000,
2770,
1002,
8827,
9... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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... |
angular.module('umbraco').directive('maxlen', function () {
return {
require: 'ngModel',
link: function (scope, el, attrs, ctrl) {
var validate = false;
var length = 999999;
if (attrs.name === 'title') {
validate = scope.model.config.allowLongTitles !== '1';
length = scope.serpTitleLength;
} else if (attrs.name === 'description') {
validate = scope.model.config.allowLongDescriptions !== '1';
length = scope.serpDescriptionLength;
}
ctrl.$parsers.unshift(function (viewValue) {
if (validate && viewValue.length > length) {
ctrl.$setValidity('maxlen', false);
} else {
ctrl.$setValidity('maxlen', true);
}
return viewValue;
});
}
};
});
| ryanmcdonough/seo-metadata | app/scripts/directives/maxlen.directive.js | JavaScript | mit | 929 | [
30522,
16108,
1012,
11336,
1006,
1005,
30524,
13075,
3091,
1027,
25897,
2683,
2683,
2683,
1025,
2065,
1006,
2012,
16344,
2015,
1012,
2171,
1027,
1027,
1027,
1005,
2516,
1005,
1007,
1063,
9398,
3686,
1027,
9531,
1012,
2944,
1012,
9530,
8873,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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... |
pinion.backend.renderer.CommentRenderer = (function($) {
var constr;
// public API -- constructor
constr = function(settings, backend) {
var _this = this,
data = settings.data;
this.$element = $("<div class='pinion-backend-renderer-CommentRenderer'></div>");
// TEXTWRAPPER
var $textWrapper = $("<div class='pinion-textWrapper'></div>")
.appendTo(this.$element);
// INFOS
$("<div class='pinion-comment-info'></div>")
// USER
.append("<div class='pinion-name'><span class='pinion-backend-icon-user'></span><span class='pinion-username'>"+data.name+"</span></div>")
// TIME
.append("<div class='pinion-time'><span class='pinion-backend-icon-clock'></span><span class='pinion-time-text'>"+data.created+"</span></div>")
.append("<div class='pinion-mail'><span class='pinion-backend-icon-mail'></span><a href='mailto:"+data.email+"' class='pinion-mail-adress'>"+data.email+"</a></div>")
.appendTo(this.$element);
// COMMENT
$("<div class='pinion-commentWrapper'><div class='pinion-comment-text'>"+data.text+"</div></div>")
.appendTo(this.$element);
var $activate = $("<div class='pinion-activate'><div class='pinion-icon'></div><div class='pinion-text'>"+pinion.translate("activate comment")+"</div></div>")
.click(function() {
if(_this.$element.hasClass("pinion-activated")) {
_this.setClean();
} else {
_this.setDirty();
}
_this.$element.toggleClass("pinion-activated")
});
// RENDERER BAR
var bar = [];
if(pinion.hasPermission("comment", "approve comment")) {
bar.push($activate);
}
if(pinion.hasPermission("comment", "delete comment")) {
bar.push(pinion.data.Delete.call(this, data, function() {
_this.info.deleted = true;
_this.fadeOut(300, function() {
_this.setDirty();
});
}));
}
if(!pinion.isEmpty(bar)) {
pinion.data.Bar.call(this, bar);
}
// INFO
pinion.data.Info.call(this, ["Time"], data);
// group events
settings.groupEvents = true;
}
// public API -- prototype
constr.prototype = {
constructor: pinion.backend.renderer.CommentRenderer,
init: function() {
this.info.id = this.settings.data.id;
},
reset: function() {
this.$element.removeClass("pinion-activated");
}
}
return constr;
}(jQuery));
| friedolinfoerder/pinion | modules/comment/backend/js/CommentRenderer.js | JavaScript | mit | 2,871 | [
30522,
9231,
3258,
1012,
2067,
10497,
1012,
17552,
2121,
1012,
7615,
7389,
4063,
2121,
1027,
1006,
3853,
1006,
1002,
1007,
1063,
13075,
9530,
3367,
2099,
1025,
1013,
1013,
2270,
17928,
1011,
1011,
9570,
2953,
9530,
3367,
2099,
1027,
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... |
require 'spec_helper'
describe "sitemap_pages" do
subject(:site) { cms_site }
subject(:node) { create_once :sitemap_node_page, filename: "docs", name: "sitemap" }
subject(:item) { Sitemap::Page.last }
subject(:index_path) { sitemap_pages_path site.id, node }
subject(:new_path) { new_sitemap_page_path site.id, node }
subject(:show_path) { sitemap_page_path site.id, node, item }
subject(:edit_path) { edit_sitemap_page_path site.id, node, item }
subject(:delete_path) { delete_sitemap_page_path site.id, node, item }
subject(:move_path) { move_sitemap_page_path site.id, node, item }
subject(:copy_path) { copy_sitemap_page_path site.id, node, item }
context "with auth" do
before { login_cms_user }
it "#index" do
visit index_path
expect(current_path).not_to eq sns_login_path
end
it "#new" do
visit new_path
within "form#item-form" do
fill_in "item[name]", with: "sample"
fill_in "item[basename]", with: "sample"
click_button "保存"
end
expect(status_code).to eq 200
expect(current_path).not_to eq new_path
expect(page).to have_no_css("form#item-form")
end
it "#show" do
visit show_path
expect(status_code).to eq 200
expect(current_path).not_to eq sns_login_path
end
it "#edit" do
visit edit_path
within "form#item-form" do
fill_in "item[name]", with: "modify"
click_button "保存"
end
expect(current_path).not_to eq sns_login_path
expect(page).to have_no_css("form#item-form")
end
it "#move" do
visit move_path
within "form" do
fill_in "destination", with: "docs/destination"
click_button "保存"
end
expect(status_code).to eq 200
expect(current_path).to eq move_path
expect(page).to have_css("form#item-form h2", text: "docs/destination.html")
within "form" do
fill_in "destination", with: "docs/sample"
click_button "保存"
end
expect(status_code).to eq 200
expect(current_path).to eq move_path
expect(page).to have_css("form#item-form h2", text: "docs/sample.html")
end
it "#copy" do
visit copy_path
within "form" do
click_button "保存"
end
expect(status_code).to eq 200
expect(current_path).to eq index_path
expect(page).to have_css("a", text: "[複製] modify")
expect(page).to have_css(".state", text: "非公開")
end
it "#delete" do
visit delete_path
within "form" do
click_button "削除"
end
expect(current_path).to eq index_path
end
end
end
| mizoki/shirasagi | spec/features/sitemap/pages_spec.rb | Ruby | mit | 2,673 | [
30522,
5478,
1005,
28699,
1035,
2393,
2121,
1005,
6235,
1000,
2609,
2863,
2361,
1035,
5530,
1000,
2079,
3395,
1006,
1024,
2609,
1007,
1063,
30524,
2361,
1000,
1065,
3395,
1006,
1024,
8875,
1007,
1063,
2609,
2863,
2361,
1024,
1024,
3931,
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... |
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<!-- NewPage -->
<html lang="de">
<head>
<!-- Generated by javadoc (version 1.7.0_55) on Sat May 03 11:14:27 CEST 2014 -->
<title>Overview</title>
<meta name="date" content="2014-05-03">
<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="Overview";
}
//-->
</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 class="navBarCell1Rev">Overview</li>
<li>Package</li>
<li>Class</li>
<li>Use</li>
<li><a href="overview-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?overview-summary.html" target="_top">Frames</a></li>
<li><a href="overview-summary.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="contentContainer">
<table class="overviewSummary" border="0" cellpadding="3" cellspacing="0" summary="Packages table, listing packages, and an explanation">
<caption><span>Packages</span><span class="tabEnd"> </span></caption>
<tr>
<th class="colFirst" scope="col">Package</th>
<th class="colLast" scope="col">Description</th>
</tr>
<tbody>
<tr class="altColor">
<td class="colFirst"><a href="de/hfu/anybeam/networkCore/package-summary.html">de.hfu.anybeam.networkCore</a></td>
<td class="colLast"> </td>
</tr>
<tr class="rowColor">
<td class="colFirst"><a href="de/hfu/anybeam/networkCore/test/package-summary.html">de.hfu.anybeam.networkCore.test</a></td>
<td class="colLast"> </td>
</tr>
</tbody>
</table>
</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 class="navBarCell1Rev">Overview</li>
<li>Package</li>
<li>Class</li>
<li>Use</li>
<li><a href="overview-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?overview-summary.html" target="_top">Frames</a></li>
<li><a href="overview-summary.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>
| doofmars/AnybeamCore | doc/overview-summary.html | HTML | gpl-2.0 | 3,928 | [
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... |
/*
* 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.harmony.sql.tests.javax.sql.rowset.serial;
import javax.sql.rowset.serial.SerialException;
import junit.framework.TestCase;
import org.apache.harmony.testframework.serialization.SerializationTest;
public class SerialExceptionTest extends TestCase {
/**
* @tests serialization/deserialization compatibility.
*/
public void testSerializationSelf() throws Exception {
SerializationTest.verifySelf(new SerialException());
}
/**
* @tests serialization/deserialization compatibility with RI.
*/
public void testSerializationCompatibility() throws Exception {
SerializationTest.verifyGolden(this, new SerialException());
}
}
| freeVM/freeVM | enhanced/java/classlib/modules/sql/src/test/java/org/apache/harmony/sql/tests/javax/sql/rowset/serial/SerialExceptionTest.java | Java | apache-2.0 | 1,516 | [
30522,
1013,
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,
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... |
# ux - Micro Xylph
ux は軽量でシンプルな動作を目標としたソフトウェアシンセサイザです。C# で作られており、Mono 上でも動作します。
## 概要
ux は [Xylph](http://www.johokagekkan.go.jp/2011/u-20/xylph.html) (シルフ) の後継として開発されています。Xylph の開発で得られた最低限必要な機能を絞り、なおかつ Xylph よりも軽快に動作するよう設計されています。C# で記述しつつ、極力高速な動作が目標です。
ux は モノフォニック、複数パート、ポルタメント、ビブラートなどの機能を持ち、音源として矩形波、16 段三角波、ユーザ波形、線形帰還シフトレジスタによる擬似ノイズ、4 オペレータ FM 音源を搭載しています。
現在 Wiki を構築中です。ハンドルの詳細など仕様については Wiki を参照してください: https://github.com/nanase/ux/wiki
## バイナリ
過去のリリース(v0.1.5-dev以前)は [Releases](//github.com/nanase/ux/releases) よりダウンロード可能です。これらは uxPlayer を同梱しており実行可能となっています。
それ以降の最新リリースでは DLL のみの配布とします。uxPlayer のバイナリダウンロードは[こちらのリポジトリ](//github.com/nanase/uxPlayer)をご参照ください。
## TODO in v0.3-dev
* 音源
- [ ] エフェクト(リバーヴ)の追加
* セレクタ(Selector)
- [ ] 新ポリフォニックアルゴリズムの追加
## 姉妹リポジトリ
* [ux++](//github.com/nanase/uxpp) - C++ 実装
* [rbux](//github.com/nanase/rbux) - Ruby 実装
## 備考
* _ux_ と表記して _Micro Xylph (マイクロシルフ)_ と呼称し、プロジェクト内での表記も `ux` です(TeX のようなものです)。
* 性能を重視するためモノフォニック実装(1パート1音)です。ただし uxMidi でのドラムパートのみ 8 音のポリフォニックです。
* この仕様により大抵の MIDI ファイルは正常に再生できません。特に和音を持っている部分は音が抜けます。
* 音色がとにかく_貧弱_です。これは音源定義XMLファイルに充分な定義が無いためです。
- リポジトリ内の以下のファイルが音源定義XMLファイルです。
+ [nanase/ux/uxConsole/ux_preset.xml](//github.com/nanase/ux/blob/v0.2-dev/uxConsole/ux_preset.xml)
+ [nanase/ux/uxPlayer/ux_preset.xml](//github.com/nanase/ux/blob/v0.2-dev/uxPlayer/ux_preset.xml)
- 最新の定義ファイルを Gist に置いています: [gist.github.com/nanase/6068233](//gist.github.com/nanase/6068233)
## 動作確認
* Mono 2.10.8.1 (Linux Mint 14 64 bit)
* .NET Framework 4.5 (Windows 7 64 bit)
* (内部プロジェクトは互換性を理由に .NET Framework 4.0 をターゲットにしています)
## ライセンス
**[MIT ライセンス](//github.com/nanase/ux/blob/v0.2-dev/LICENSE)**
Copyright © 2013-2014 Tomona Nanase
| nanase/ux | README.md | Markdown | mit | 3,064 | [
30522,
1001,
1057,
2595,
1011,
12702,
1060,
8516,
8458,
1057,
2595,
1672,
100,
100,
1665,
30232,
30263,
30246,
30259,
30193,
100,
100,
1690,
1918,
100,
100,
1636,
1039,
1001,
1665,
100,
1685,
30214,
30191,
30176,
30212,
1635,
18847,
1742,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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... |
jQuery(document).ready(function($){
// Pricing Tables Deleting
$('.uds-pricing-admin-table .pricing-delete').click(function(){
if(!confirm("Really delete table?")) {
return false;
}
});
// products
$('#uds-pricing-products form').submit(function(){
$('#uds-pricing-products .product').each(function(i, el){
$("input[type=checkbox]", this).each(function() {
$(this).attr('name', $(this).attr('name').replace('[]', '[' + i + ']'));
});
$("input[type=radio]", this).each(function() {
$(this).val(i);
});
});
});
// products moving
$('#uds-pricing-products').sortable({
containment: '#uds-pricing-products',
cursor: 'crosshair',
forcePlaceholderSize: true,
forceHelpserSize: true,
handle: '.move',
items: '.product',
placeholder: 'placeholder',
opacity: 0.6,
tolerance: 'pointer',
axis: 'y'
});
// products deleting
$('#uds-pricing-products .delete').click(function(){
if(confirm("Really delete product?")) {
$(this).parents('.product').slideUp(300, function(){
$(this).remove();
});
}
});
// products collapsing
$('#uds-pricing-products h3.collapsible').click(function(){
$('.options', $(this).parent()).slideToggle(300);
$(this).add($(this).parent()).toggleClass('collapsed');
}).trigger('click');
var collapsed = true;
$('.collapse-all').click(function(){
if(collapsed) {
$('.options').slideDown(300);
$('.product').add('h3.collapsible').removeClass('collapsed');
collapsed = false;
$(this).html('Collapse all');
} else {
$('.options').slideUp(300);
$('.product').add('h3.collapsible').addClass('collapsed');
collapsed = true;
$(this).html('Open all');
}
return false;
});
// table changer
$('.uds-change-table').click(function(){
window.location = window.location + "&uds_pricing_edit=" + $('.uds-load-pricing-table').val();
});
//structure
$('#uds-pricing-properties table').sortable({
containment: '#uds-pricing-properties',
cursor: 'crosshair',
forcePlaceHolderSize: true,
handle: '.move',
items: 'tr',
axis: 'y'
});
// properties deleting
$('#uds-pricing-properties .delete').live('click', function(){
if(confirm("Really delete?")) {
$(this).parents("tr").remove();
$('#uds-pricing-properties table').sortable('refresh');
}
});
// properties adding
var empty = $('#uds-pricing-properties tr:last').clone();
$('#uds-pricing-properties .add').live('click', function(){
$('#uds-pricing-properties table').append($(empty).clone());
$('#uds-pricing-properties table').sortable('refresh');
});
// Tooltips
$('.tooltip').hover(function(){
$tt = $(this).parent().find('.tooltip-content');
$tt.stop().css({
display: 'block',
top: $(this).position().top,
left: $(this).position().left + 40 + 'px',
opacity: 0
}).animate({
opacity: 1
}, 300);
}, function(){
$tt = $(this).parent().find('.tooltip-content');
$tt.stop().css({
opacity: 1
}).animate({
opacity: 0
}, {
duration: 300,
complete: function(){
$(this).css('display', 'none');
}
});
});
}); | How2ForFree/development | wp-content/themes/Superb_v1.0.1/Superb/uPricing/js/pricing-admin.js | JavaScript | gpl-2.0 | 3,075 | [
30522,
1046,
4226,
2854,
1006,
6254,
1007,
1012,
3201,
1006,
3853,
1006,
1002,
1007,
1063,
1013,
1013,
20874,
7251,
3972,
20624,
3070,
1002,
1006,
1005,
1012,
20904,
2015,
1011,
20874,
1011,
4748,
10020,
1011,
2795,
1012,
20874,
1011,
3972,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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... |
// $Id$
// This file is part of CDS Invenio.
// Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008 CERN.
//
// CDS Invenio 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.
//
// CDS Invenio 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 CDS Invenio; if not, write to the Free Software Foundation, Inc.,
// 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include "intbitset.h"
const int wordbytesize = sizeof(word_t);
const int wordbitsize = sizeof(word_t) * 8;
const int maxelem = INT_MAX;
IntBitSet *intBitSetCreate(register const int size, const bool_t trailing_bits) {
register word_t *base;
register word_t *end;
IntBitSet *ret = malloc(sizeof(IntBitSet));
// At least one word -> the one who represent the trailing_bits
ret->allocated = (size / wordbitsize + 1);
ret->size = 0; // trailing_bits
ret->trailing_bits = trailing_bits ? (word_t) ~0 : 0;
if (trailing_bits) {
base = ret->bitset = malloc(ret->allocated * wordbytesize);
end = base + ret->allocated;
for (; base < end; ++base)
*base = (word_t) ~0;
ret->tot = -1;
} else {
ret->bitset = calloc(ret->allocated, wordbytesize);
ret->tot = 0;
}
return ret;
}
IntBitSet *intBitSetCreateNoAllocate() {
IntBitSet *ret = malloc(sizeof(IntBitSet));
ret->allocated = 0;
ret->size = -1;
ret->trailing_bits = 0;
ret->bitset = NULL;
return ret;
}
IntBitSet *intBitSetResetFromBuffer(IntBitSet *const bitset, const void *const buf, const Py_ssize_t bufsize) {
bitset->allocated = bufsize/wordbytesize;
bitset->bitset = realloc(bitset->bitset, bufsize);
bitset->tot = -1;
bitset->size = bitset->allocated - 1;
memcpy(bitset->bitset, buf, bufsize);
bitset->trailing_bits = *(bitset->bitset + bitset->allocated - 1);
return bitset;
}
IntBitSet *intBitSetReset(IntBitSet *const bitset) {
bitset->allocated = 1;
bitset->size = 0;
*bitset->bitset = 0;
bitset->trailing_bits = 0;
return bitset;
}
IntBitSet *intBitSetCreateFromBuffer(const void *const buf, const Py_ssize_t bufsize) {
IntBitSet *ret = malloc(sizeof(IntBitSet));
ret->allocated = bufsize/wordbytesize;
ret->bitset = malloc(bufsize);
ret->size = ret->allocated - 1;;
ret->tot = -1;
memcpy(ret->bitset, buf, bufsize);
ret->trailing_bits = ret->bitset[ret->allocated - 1];
return ret;
}
void intBitSetDestroy(IntBitSet *const bitset) {
free(bitset->bitset);
free(bitset);
}
IntBitSet *intBitSetClone(const IntBitSet * const bitset) {
IntBitSet *ret = malloc(sizeof(IntBitSet));
ret->size = bitset->size;
ret->tot = bitset->tot;
ret->trailing_bits = bitset->trailing_bits;
ret->allocated = bitset->allocated;
ret->bitset = malloc(bitset->allocated * wordbytesize);
memcpy(ret->bitset, bitset->bitset, bitset->allocated * wordbytesize);
return ret;
}
int intBitSetGetSize(IntBitSet * const bitset) {
register word_t *base;
register word_t *end;
if (bitset->size >= 0)
return bitset->size;
base = bitset->bitset;
end = bitset->bitset + bitset->allocated - 2;
for (; base < end && *end == bitset->trailing_bits; --end);
bitset->size = ((int) (end - base) + 1);
return bitset->size;
}
int intBitSetGetTot(IntBitSet *const bitset) {
register word_t* base;
register int i;
register int tot;
register word_t *end;
if (bitset->trailing_bits)
return -1;
if (bitset->tot < 0) {
end = bitset->bitset + bitset->allocated;
tot = 0;
for (base = bitset->bitset; base < end; ++base)
if (*base)
for (i=0; i<wordbitsize; ++i)
if ((*base & ((word_t) 1 << i)) != 0) {
++tot;
}
bitset->tot = tot;
}
return bitset->tot;
}
int intBitSetGetAllocated(const IntBitSet * const bitset) {
return bitset->allocated;
}
void intBitSetResize(IntBitSet *const bitset, register const int allocated) {
register word_t *base;
register word_t *end;
if (allocated > bitset->allocated) {
bitset->bitset = realloc(bitset->bitset, allocated * wordbytesize);
base = bitset->bitset + bitset->allocated;
end = bitset->bitset + allocated;
for (; base<end; ++base)
*(base) = bitset->trailing_bits;
bitset->allocated = allocated;
}
}
bool_t intBitSetIsInElem(const IntBitSet * const bitset, register const int elem) {
return ((elem < bitset->allocated * wordbitsize) ?
(bitset->bitset[elem / wordbitsize] & ((word_t) 1 << ((word_t)elem % (word_t)wordbitsize))) != 0 : bitset->trailing_bits != 0);
}
void intBitSetAddElem(IntBitSet *const bitset, register const int elem) {
if (elem >= (bitset->allocated - 1) * wordbitsize) {
if (bitset->trailing_bits)
return;
else
intBitSetResize(bitset, (elem + elem/10)/wordbitsize+2);
}
bitset->bitset[elem / wordbitsize] |= ((word_t) 1 << (elem % wordbitsize));
bitset->tot = -1;
bitset->size = -1;
}
void intBitSetDelElem(IntBitSet *const bitset, register const int elem) {
if (elem >= (bitset->allocated - 1) * wordbitsize) {
if (!bitset->trailing_bits)
return;
else
intBitSetResize(bitset, (elem + elem/10)/wordbitsize+2);
}
bitset->bitset[elem / wordbitsize] &= (word_t) ~((word_t) 1 << (elem % wordbitsize));
bitset->tot = -1;
bitset->size = -1;
}
bool_t intBitSetEmpty(const IntBitSet *const bitset) {
register word_t *end;
register word_t *base;
if (bitset->trailing_bits) return 0;
if (bitset->tot == 0) return 1;
end = bitset->bitset + bitset->allocated;
for (base = bitset->bitset; base < end; ++base)
if (*base) return 0;
return 1;
}
int intBitSetAdaptMax(IntBitSet *const x, IntBitSet *const y) {
// Good idea but broken, it is kept for better time...
// register int sizex = intBitSetGetSize(x);
// register int sizey = intBitSetGetSize(y);
// register int sizemax = ((sizex > sizey) ? sizex : sizey) + 1;
// if (sizemax > x->allocated)
// intBitSetResize(x, sizemax);
// if (sizemax > y->allocated)
// intBitSetResize(y, sizemax);
// return sizemax;*/
register int allocated = (x->allocated > y->allocated) ? x->allocated : y->allocated;
if (allocated > x->allocated)
intBitSetResize(x, allocated);
if (allocated > y->allocated)
intBitSetResize(y, allocated);
return allocated;
}
int intBitSetAdaptMin(IntBitSet *const x, IntBitSet *const y) {
register int sizex;
register int sizey;
if (x->trailing_bits || y->trailing_bits)
return intBitSetAdaptMax(x, y);
sizex = intBitSetGetSize(x);
sizey = intBitSetGetSize(y);
return ((sizex < sizey) ? sizex : sizey) + 1;
}
IntBitSet *intBitSetUnion(IntBitSet *const x, IntBitSet *const y) {
register word_t *xbase;
register word_t *xend;
register word_t *ybase;
register word_t *retbase;
register IntBitSet * ret = malloc(sizeof (IntBitSet));
ret->allocated = intBitSetAdaptMax(x, y);
xbase = x->bitset;
xend = x->bitset+ret->allocated;
ybase = y->bitset;
retbase = ret->bitset = malloc(wordbytesize * ret->allocated);
ret->size = -1;
ret->tot = -1;
for (; xbase < xend; ++xbase, ++ybase, ++retbase)
*(retbase) = *(xbase) | *(ybase);
ret->trailing_bits = x->trailing_bits | y->trailing_bits;
return ret;
}
IntBitSet *intBitSetXor(IntBitSet *const x, IntBitSet *const y) {
register word_t *xbase;
register word_t *xend;
register word_t *ybase;
register word_t *retbase;
register IntBitSet * ret = malloc(sizeof (IntBitSet));
ret->allocated = intBitSetAdaptMax(x, y);
xbase = x->bitset;
xend = x->bitset+ret->allocated;
ybase = y->bitset;
retbase = ret->bitset = malloc(wordbytesize * ret->allocated);
ret->size = -1;
ret->tot = -1;
for (; xbase < xend; ++xbase, ++ybase, ++retbase)
*(retbase) = *(xbase) ^ *(ybase);
ret->trailing_bits = x->trailing_bits ^ y->trailing_bits;
return ret;
}
IntBitSet *intBitSetIntersection(IntBitSet *const x, IntBitSet *const y) {
register word_t *xbase;
register word_t *xend;
register word_t *ybase;
register word_t *retbase;
register IntBitSet * ret = malloc(sizeof (IntBitSet));
ret->allocated = intBitSetAdaptMin(x, y);
xbase = x->bitset;
xend = x->bitset+ret->allocated;
ybase = y->bitset;
retbase = ret->bitset = malloc(wordbytesize * ret->allocated);
ret->size = -1;
ret->tot = -1;
for (; xbase < xend; ++xbase, ++ybase, ++retbase)
*(retbase) = *(xbase) & *(ybase);
ret->trailing_bits = x->trailing_bits & y->trailing_bits;
return ret;
}
IntBitSet *intBitSetSub(IntBitSet *const x, IntBitSet *const y) {
register word_t *xbase;
register word_t *ybase;
register word_t *retbase;
register word_t *retend;
register IntBitSet * ret = malloc(sizeof (IntBitSet));
register int tmpsize = intBitSetAdaptMin(x, y);
ret->allocated = x->allocated > tmpsize ? x->allocated : tmpsize;
xbase = x->bitset;
ybase = y->bitset;
retbase = ret->bitset = malloc(wordbytesize * ret->allocated);
retend = ret->bitset+tmpsize;
ret->size = -1;
ret->tot = -1;
for (; retbase < retend; ++xbase, ++ybase, ++retbase)
*(retbase) = *(xbase) & ~*(ybase);
retend = ret->bitset+ret->allocated;
for (; retbase < retend; ++xbase, ++retbase)
*retbase = *xbase & ~y->trailing_bits;
ret->trailing_bits = x->trailing_bits & ~y->trailing_bits;
return ret;
}
IntBitSet *intBitSetIUnion(IntBitSet *const dst, IntBitSet *const src) {
register word_t *dstbase;
register word_t *srcbase;
register word_t *srcend;
register int allocated = intBitSetAdaptMax(dst, src);
dstbase = dst->bitset;
srcbase = src->bitset;
srcend = src->bitset + allocated;
for (; srcbase < srcend; ++dstbase, ++srcbase)
*dstbase |= *srcbase;
dst->size = -1;
dst->tot = -1;
dst->trailing_bits |= src->trailing_bits;
return dst;
}
IntBitSet *intBitSetIXor(IntBitSet *const dst, IntBitSet *const src) {
register word_t *dstbase;
register word_t *srcbase;
register word_t *srcend;
register int allocated = intBitSetAdaptMax(dst, src);
dstbase = dst->bitset;
srcbase = src->bitset;
srcend = src->bitset + allocated;
for (; srcbase < srcend; ++dstbase, ++srcbase)
*dstbase ^= *srcbase;
dst->size = -1;
dst->tot = -1;
dst->trailing_bits ^= src->trailing_bits;
return dst;
}
IntBitSet *intBitSetIIntersection(IntBitSet *const dst, IntBitSet *const src) {
register word_t *dstbase;
register word_t *srcbase;
register word_t *dstend;
dst->allocated = intBitSetAdaptMin(dst, src);
dstbase = dst->bitset;
srcbase = src->bitset;
dstend = dst->bitset + dst->allocated;
for (; dstbase < dstend; ++dstbase, ++srcbase)
*dstbase &= *srcbase;
dst->size = -1;
dst->tot = -1;
dst->trailing_bits &= src->trailing_bits;
return dst;
}
IntBitSet *intBitSetISub(IntBitSet *const dst, IntBitSet *const src) {
register word_t *dstbase;
register word_t *srcbase;
register word_t *dstend;
register int allocated = intBitSetAdaptMin(dst, src);
dstbase = dst->bitset;
srcbase = src->bitset;
dstend = dst->bitset + allocated;
for (; dstbase < dstend; ++dstbase, ++srcbase)
*dstbase &= ~*srcbase;
dstend = dst->bitset + dst->allocated;
for (; dstbase < dstend; ++dstbase)
*dstbase &= ~src->trailing_bits;
dst->size = -1;
dst->tot = -1;
dst->trailing_bits &= ~src->trailing_bits;
return dst;
}
int intBitSetGetNext(const IntBitSet *const x, register int last) {
register word_t* base = x->bitset + (++last / wordbitsize);
register int i = last % wordbitsize;
register word_t *end = x->bitset + x->allocated;
while(base < end) {
if (*base)
for (; i<wordbitsize; ++i)
if ((*base & ((word_t) 1 << (word_t) i)))
return (int) i + (int) (base - x->bitset) * wordbitsize;
i = 0;
++base;
}
return x->trailing_bits ? last : -2;
}
unsigned char intBitSetCmp(IntBitSet *const x, IntBitSet *const y) {
register word_t *xbase;
register word_t *xend;
register word_t *ybase;
register unsigned char ret = 0;
register int allocated = intBitSetAdaptMax(x, y);
xbase = x->bitset;
xend = x->bitset+allocated;
ybase = y->bitset;
for (; ret != 3 && xbase<xend; ++xbase, ++ybase)
ret |= (*ybase != (*xbase | *ybase)) * 2 + (*xbase != (*xbase | *ybase));
ret |= (y->trailing_bits != (x->trailing_bits | y->trailing_bits)) * 2 + (x->trailing_bits != (x->trailing_bits | y->trailing_bits));
return ret;
}
| ppiotr/Bibedit-some-refactoring | modules/miscutil/lib/intbitset_impl.c | C | gpl-2.0 | 13,509 | [
30522,
1013,
1013,
1002,
8909,
1002,
1013,
1013,
2023,
5371,
2003,
2112,
1997,
14340,
1999,
8159,
3695,
1012,
1013,
1013,
9385,
1006,
1039,
1007,
2526,
1010,
2494,
1010,
2432,
1010,
2384,
1010,
2294,
1010,
2289,
1010,
2263,
8292,
6826,
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 2017 Google Inc.
//
// 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 codeu.chat.client.core;
import java.util.Arrays;
import java.util.ArrayList;
import java.util.Collection;
import codeu.chat.common.BasicView;
import codeu.chat.common.User;
import codeu.chat.util.Uuid;
import codeu.chat.util.connections.ConnectionSource;
public final class Context {
private final BasicView view;
private final Controller controller;
public Context(ConnectionSource source) {
this.view = new View(source);
this.controller = new Controller(source);
}
public UserContext create(String name) {
final User user = controller.newUser(name);
return user == null ?
null :
new UserContext(user, view, controller);
}
public Iterable<UserContext> allUsers() {
final Collection<UserContext> users = new ArrayList<>();
for (final User user : view.getUsers()) {
users.add(new UserContext(user, view, controller));
}
return users;
}
}
| crepric/codeu_mirrored_test_1 | src/codeu/chat/client/core/Context.java | Java | apache-2.0 | 1,510 | [
30522,
1013,
1013,
9385,
2418,
8224,
4297,
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,
2089,
2025,
2224,
2023,
5371,
3272,
1999,
12... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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) 2014 Tavendo GmbH
##
## 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.
##
###############################################################################
from twisted.internet import reactor
from twisted.internet.defer import inlineCallbacks
from autobahn.wamp.types import CallResult
from autobahn.twisted.wamp import ApplicationSession
class Component(ApplicationSession):
"""
Application component that provides procedures which
return complex results.
"""
def onConnect(self):
self.join("realm1")
def onJoin(self, details):
def add_complex(a, ai, b, bi):
return CallResult(c = a + b, ci = ai + bi)
self.register(add_complex, 'com.myapp.add_complex')
def split_name(fullname):
forename, surname = fullname.split()
return CallResult(forename, surname)
self.register(split_name, 'com.myapp.split_name')
| robtandy/AutobahnPython | examples/twisted/wamp/basic/rpc/complex/backend.py | Python | apache-2.0 | 1,506 | [
30522,
1001,
1001,
1001,
1001,
1001,
1001,
1001,
1001,
1001,
1001,
1001,
1001,
1001,
1001,
1001,
1001,
1001,
1001,
1001,
1001,
1001,
1001,
1001,
1001,
1001,
1001,
1001,
1001,
1001,
1001,
1001,
1001,
1001,
1001,
1001,
1001,
1001,
1001,
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... |
---
layout: extending
title: Extending Vagrant - I18n
current: I18n
---
# I18n
Vagrant comes setup with the Ruby I18n (internationalization) library,
which allows you to store all your strings in a YAML file. While its
not required, there are many benefits to this:
1. Easier to maintain the various strings of your plugin
2. Easy for others to translate your plugin, if they so choose
3. Removes strings from your code logic, which helps since strings look ugly
in the code and clutter the flow of logic.
Again, its completely optional, but using it is so easy that is recommended.
## Using I18n
First, define your translations in a file, which I typically name `en.yml`
(since its for the `en` locale). It looks like this:
{% highlight yaml %}
en:
vagrant:
plugins:
my_plugin:
hello: "Hello, %{name}!"
{% endhighlight %}
Once that is defined, you have to add that file to the I18n load path:
{% highlight ruby %}
I18n.load_path << "/path/to/my/en.yml"
{% endhighlight %}
Then, once its adding, you can use your translations anywhere you'd like:
{% highlight ruby %}
I18n.t("vagrant.plugins.my_plugin.hello", :name => "Mitchell")
{% endhighlight %}
The second parameter is an optional hash of interpolation variables, which
are interpolated into the translation. The `%{name}` is replaced with the
`name` interpolation variable. If you don't have any variables to interpolate,
you can just omit the parameter.
| FriendsOfVagrant/friendsofvagrant.github.com | v2/docs/extending/i18n.md | Markdown | mit | 1,446 | [
30522,
1011,
1011,
1011,
9621,
1024,
8402,
2516,
1024,
8402,
12436,
18980,
1011,
1045,
15136,
2078,
2783,
1024,
1045,
15136,
2078,
1011,
1011,
1011,
1001,
1045,
15136,
2078,
12436,
18980,
3310,
16437,
2007,
1996,
10090,
1045,
15136,
2078,
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 ActionRefreshReposStartup
{
public function __construct($args)
{
global $neardTools;
if (isset($args[0]) && !empty($args[0]) && isset($args[1])) {
if ($args[0] == ActionRefreshRepos::GIT) {
$neardTools->getGit()->setScanStartup($args[1]);
} elseif ($args[0] == ActionRefreshRepos::SVN) {
$neardTools->getSvn()->setScanStartup($args[1]);
}
}
}
}
| Tasarinan/neard | core/classes/actions/class.action.refreshReposStartup.php | PHP | lgpl-3.0 | 471 | [
30522,
1026,
1029,
25718,
2465,
2895,
2890,
19699,
9953,
2890,
6873,
4757,
7559,
8525,
2361,
1063,
2270,
3853,
1035,
1035,
9570,
1006,
1002,
12098,
5620,
1007,
1063,
3795,
1002,
2379,
11927,
13669,
2015,
1025,
2065,
1006,
26354,
3388,
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... |
"""Test Workbench Runtime"""
from unittest import TestCase
import mock
from django.conf import settings
from xblock.fields import Scope
from xblock.runtime import KeyValueStore
from xblock.runtime import KvsFieldData
from xblock.reference.user_service import UserService
from ..runtime import WorkbenchRuntime, ScenarioIdManager, WorkbenchDjangoKeyValueStore
class TestScenarioIds(TestCase):
"""
Test XBlock Scenario IDs
"""
def setUp(self):
# Test basic ID generation meets our expectations
self.id_mgr = ScenarioIdManager()
def test_no_scenario_loaded(self):
self.assertEqual(self.id_mgr.create_definition("my_block"), ".my_block.d0")
def test_should_increment(self):
self.assertEqual(self.id_mgr.create_definition("my_block"), ".my_block.d0")
self.assertEqual(self.id_mgr.create_definition("my_block"), ".my_block.d1")
def test_slug_support(self):
self.assertEqual(
self.id_mgr.create_definition("my_block", "my_slug"),
".my_block.my_slug.d0"
)
self.assertEqual(
self.id_mgr.create_definition("my_block", "my_slug"),
".my_block.my_slug.d1"
)
def test_scenario_support(self):
self.test_should_increment()
# Now that we have a scenario, our definition numbering starts over again.
self.id_mgr.set_scenario("my_scenario")
self.assertEqual(self.id_mgr.create_definition("my_block"), "my_scenario.my_block.d0")
self.assertEqual(self.id_mgr.create_definition("my_block"), "my_scenario.my_block.d1")
self.id_mgr.set_scenario("another_scenario")
self.assertEqual(self.id_mgr.create_definition("my_block"), "another_scenario.my_block.d0")
def test_usages(self):
# Now make sure our usages are attached to definitions
self.assertIsNone(self.id_mgr.last_created_usage_id())
self.assertEqual(
self.id_mgr.create_usage("my_scenario.my_block.d0"),
"my_scenario.my_block.d0.u0"
)
self.assertEqual(
self.id_mgr.create_usage("my_scenario.my_block.d0"),
"my_scenario.my_block.d0.u1"
)
self.assertEqual(self.id_mgr.last_created_usage_id(), "my_scenario.my_block.d0.u1")
def test_asides(self):
definition_id = self.id_mgr.create_definition('my_block')
usage_id = self.id_mgr.create_usage(definition_id)
aside_definition, aside_usage = self.id_mgr.create_aside(definition_id, usage_id, 'my_aside')
self.assertEqual(self.id_mgr.get_aside_type_from_definition(aside_definition), 'my_aside')
self.assertEqual(self.id_mgr.get_definition_id_from_aside(aside_definition), definition_id)
self.assertEqual(self.id_mgr.get_aside_type_from_usage(aside_usage), 'my_aside')
self.assertEqual(self.id_mgr.get_usage_id_from_aside(aside_usage), usage_id)
class TestKVStore(TestCase):
"""
Test the Workbench KVP Store
"""
def setUp(self):
self.kvs = WorkbenchDjangoKeyValueStore()
self.key = KeyValueStore.Key(
scope=Scope.content,
user_id="rusty",
block_scope_id="my_scenario.my_block.d0",
field_name="age"
)
def test_storage(self):
self.assertFalse(self.kvs.has(self.key))
self.kvs.set(self.key, 7)
self.assertTrue(self.kvs.has(self.key))
self.assertEqual(self.kvs.get(self.key), 7)
self.kvs.delete(self.key)
self.assertFalse(self.kvs.has(self.key))
class StubService(object):
"""Empty service to test loading additional services. """
pass
class ExceptionService(object):
"""Stub service that raises an exception on init. """
def __init__(self):
raise Exception("Kaboom!")
class TestServices(TestCase):
"""
Test XBlock runtime services
"""
def setUp(self):
super(TestServices, self).setUp()
self.xblock = mock.Mock()
def test_default_services(self):
runtime = WorkbenchRuntime('test_user')
self._assert_default_services(runtime)
@mock.patch.dict(settings.WORKBENCH['services'], {
'stub': 'workbench.test.test_runtime.StubService'
})
def test_settings_adds_services(self):
runtime = WorkbenchRuntime('test_user')
# Default services should still be available
self._assert_default_services(runtime)
# An additional service should be provided
self._assert_service(runtime, 'stub', StubService)
# Check that the service has the runtime attribute set
service = runtime.service(self.xblock, 'stub')
self.assertIs(service.runtime, runtime)
@mock.patch.dict(settings.WORKBENCH['services'], {
'not_found': 'workbench.test.test_runtime.NotFoundService'
})
def test_could_not_find_service(self):
runtime = WorkbenchRuntime('test_user')
# Default services should still be available
self._assert_default_services(runtime)
# The additional service should NOT be available
self.assertIs(runtime.service(self.xblock, 'not_found'), None)
@mock.patch.dict(settings.WORKBENCH['services'], {
'exception': 'workbench.test.test_runtime.ExceptionService'
})
def test_runtime_service_initialization_failed(self):
runtime = WorkbenchRuntime('test_user')
# Default services should still be available
self._assert_default_services(runtime)
# The additional service should NOT be available
self.assertIs(runtime.service(self.xblock, 'exception'), None)
def _assert_default_services(self, runtime):
"""Check that the default services are available. """
self._assert_service(runtime, 'field-data', KvsFieldData)
self._assert_service(runtime, 'user', UserService)
def _assert_service(self, runtime, service_name, service_class):
"""Check that a service is loaded. """
service_instance = runtime.service(self.xblock, service_name)
self.assertIsInstance(service_instance, service_class)
| Lyla-Fischer/xblock-sdk | workbench/test/test_runtime.py | Python | agpl-3.0 | 6,112 | [
30522,
1000,
1000,
1000,
3231,
2147,
10609,
2818,
2448,
30524,
2013,
1060,
23467,
1012,
2448,
7292,
12324,
24888,
15951,
2850,
2696,
2013,
1060,
23467,
1012,
4431,
1012,
5310,
1035,
2326,
12324,
5198,
2121,
7903,
2063,
2013,
1012,
1012,
244... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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... |
local unpack = table.unpack or unpack
--- Bit operations
local ok,bit
if _VERSION == "Lua 5.3" then
bit = (load [[ return {
band = function(x, y) return x & y end,
bor = function(x, y) return x | y end,
bxor = function(x, y) return x ~ y end,
bnot = function(x) return ~x end,
rshift = function(x, n) return x >> n end,
lshift = function(x, n) return x << n end,
} ]])()
else
ok,bit = pcall(require,"bit")
if not ok then bit = bit32 end
end
assert(type(bit) == "table", "module for bitops not found")
--- default sleep
local default_sleep
do
local ok, mod = pcall(require, "socket")
if ok and type(mod) == "table" then
default_sleep = mod.sleep
else
default_sleep = function(n)
local t0 = os.clock()
while true do
local delta = os.clock() - t0
if (delta < 0) or (delta > n) then break end
end
end
end
end
--- Helpers
local xdefv = function(ktype)
if ktype == "list" then
return {head = 0, tail = 0}
elseif ktype == "zset" then
return {
list = {},
set = {},
}
else return {} end
end
local xgetr = function(self, k, ktype)
if self.data[k] then
assert(
(self.data[k].ktype == ktype),
"ERR Operation against a key holding the wrong kind of value"
)
assert(self.data[k].value)
return self.data[k].value
else return xdefv(ktype) end
end
local xgetw = function(self, k, ktype)
if self.data[k] and self.data[k].value then
assert(
(self.data[k].ktype == ktype),
"ERR Operation against a key holding the wrong kind of value"
)
else
self.data[k] = {ktype = ktype, value = xdefv(ktype)}
end
return self.data[k].value
end
local empty = function(self, k)
local v, t = self.data[k].value, self.data[k].ktype
if t == nil then
return true
elseif t == "string" then
return not v[1]
elseif (t == "hash") or (t == "set") then
for _,_ in pairs(v) do return false end
return true
elseif t == "list" then
return v.head == v.tail
elseif t == "zset" then
if #v.list == 0 then
for _,_ in pairs(v.set) do error("incoherent") end
return true
else
for _,_ in pairs(v.set) do return(false) end
error("incoherent")
end
else error("unsupported") end
end
local cleanup = function(self, k)
if empty(self, k) then self.data[k] = nil end
end
local is_integer = function(x)
return (type(x) == "number") and (math.floor(x) == x)
end
local overflows = function(n)
return (n > 2^53-1) or (n < -2^53+1)
end
local is_bounded_integer = function(x)
return (is_integer(x) and (not overflows(x)))
end
local is_finite_number = function(x)
return (type(x) == "number") and (x > -math.huge) and (x < math.huge)
end
local toint = function(x)
if type(x) == "string" then x = tonumber(x) end
return is_bounded_integer(x) and x or nil
end
local tofloat = function(x)
if type(x) == "number" then return x end
if type(x) ~= "string" then return nil end
local r = tonumber(x)
if r then return r end
if x == "inf" or x == "+inf" then
return math.huge
elseif x == "-inf" then
return -math.huge
else return nil end
end
local tostr = function(x)
if is_bounded_integer(x) then
return string.format("%d", x)
else return tostring(x) end
end
local char_bitcount = function(x)
assert(
(type(x) == "number") and
(math.floor(x) == x) and
(x >= 0) and (x < 256)
)
local n = 0
while x ~= 0 do
x = bit.band(x, x-1)
n = n+1
end
return n
end
local chkarg = function(x)
if type(x) == "number" then x = tostr(x) end
assert(type(x) == "string")
return x
end
local chkargs = function(n, ...)
local arg = {...}
assert(#arg == n)
for i=1,n do arg[i] = chkarg(arg[i]) end
return unpack(arg)
end
local getargs = function(...)
local arg = {...}
local n = #arg; assert(n > 0)
for i=1,n do arg[i] = chkarg(arg[i]) end
return arg
end
local getargs_as_map = function(...)
local arg, r = getargs(...), {}
assert(#arg%2 == 0)
for i=1,#arg,2 do r[arg[i]] = arg[i+1] end
return r
end
local chkargs_wrap = function(f, n)
assert( (type(f) == "function") and (type(n) == "number") )
return function(self, ...) return f(self, chkargs(n, ...)) end
end
local lset_to_list = function(s)
local r = {}
for v,_ in pairs(s) do r[#r+1] = v end
return r
end
local nkeys = function(x)
local r = 0
for _,_ in pairs(x) do r = r + 1 end
return r
end
--- Commands
-- keys
local del = function(self, ...)
local arg = getargs(...)
local r = 0
for i=1,#arg do
if self.data[arg[i]] then r = r + 1 end
self.data[arg[i]] = nil
end
return r
end
local exists = function(self, k)
return not not self.data[k]
end
local keys = function(self, pattern)
assert(type(pattern) == "string")
-- We want to convert the Redis pattern to a Lua pattern.
-- Start by escaping dashes *outside* character classes.
-- We also need to escape percents here.
local t, p, n = {}, 1, #pattern
local p1, p2
while true do
p1, p2 = pattern:find("%[.+%]", p)
if p1 then
if p1 > p then
t[#t+1] = {true, pattern:sub(p, p1-1)}
end
t[#t+1] = {false, pattern:sub(p1, p2)}
p = p2+1
if p > n then break end
else
t[#t+1] = {true, pattern:sub(p, n)}
break
end
end
for i=1,#t do
if t[i][1] then
t[i] = t[i][2]:gsub("[%%%-]", "%%%0")
else t[i] = t[i][2]:gsub("%%", "%%%%") end
end
-- Remaining Lua magic chars are: '^$().[]*+?' ; escape them except '*?[]'
-- Then convert '\' to '%', '*' to '.*' and '?' to '.'. Leave '[]' as is.
-- Wrap in '^$' to enforce bounds.
local lp = "^" .. table.concat(t):gsub("[%^%$%(%)%.%+]", "%%%0")
:gsub("\\", "%%"):gsub("%*", ".*"):gsub("%?", ".") .. "$"
local r = {}
for k,_ in pairs(self.data) do
if k:match(lp) then r[#r+1] = k end
end
return r
end
local _type = function(self, k)
return self.data[k] and self.data[k].ktype or "none"
end
local randomkey = function(self)
local ks = lset_to_list(self.data)
local n = #ks
if n > 0 then
return ks[math.random(1, n)]
else return nil end
end
local rename = function(self, k, k2)
assert((k ~= k2) and self.data[k])
self.data[k2] = self.data[k]
self.data[k] = nil
return true
end
local renamenx = function(self, k, k2)
if self.data[k2] then
return false
else
return rename(self, k, k2)
end
end
-- strings
local getrange, incrby, set
local append = function(self, k, v)
local x = xgetw(self, k, "string")
x[1] = (x[1] or "") .. v
return #x[1]
end
local bitcount = function(self, k, i1, i2)
k = chkarg(k)
local s
if i1 or i2 then
assert(i1 and i2, "ERR syntax error")
s = getrange(self, k, i1, i2)
else
s = xgetr(self, k, "string")[1] or ""
end
local r, bytes = 0,{s:byte(1, -1)}
for i=1,#bytes do
r = r + char_bitcount(bytes[i])
end
return r
end
local bitop = function(self, op, k, ...)
assert(type(op) == "string")
op = op:lower()
assert(
(op == "and") or
(op == "or") or
(op == "xor") or
(op == "not"),
"ERR syntax error"
)
k = chkarg(k)
local arg = {...}
local good_arity = (op == "not") and (#arg == 1) or (#arg > 0)
assert(good_arity, "ERR wrong number of arguments for 'bitop' command")
local l, vals = 0, {}
local s
for i=1,#arg do
s = xgetr(self, arg[i], "string")[1] or ""
if #s > l then l = #s end
vals[i] = s
end
if l == 0 then
del(self, k)
return 0
end
local vector_mt = {__index=function() return 0 end}
for i=1,#vals do
vals[i] = setmetatable({vals[i]:byte(1, -1)}, vector_mt)
end
local r = {}
if op == "not" then
assert(#vals[1] == l)
for i=1,l do
r[i] = bit.band(bit.bnot(vals[1][i]), 0xff)
end
else
local _op = bit["b" .. op]
for i=1,l do
local t = {}
for j=1,#vals do t[j] = vals[j][i] end
r[i] = _op(unpack(t))
end
end
set(self, k, string.char(unpack(r)))
return l
end
local decr = function(self, k)
return incrby(self, k, -1)
end
local decrby = function(self, k, n)
n = toint(n)
assert(n, "ERR value is not an integer or out of range")
return incrby(self, k, -n)
end
local get = function(self, k)
local x = xgetr(self, k, "string")
return x[1]
end
local getbit = function(self, k, offset)
k = chkarg(k)
offset = toint(offset)
assert(
(offset >= 0),
"ERR bit offset is not an integer or out of range"
)
local bitpos = offset % 8 -- starts at 0
local bytepos = (offset - bitpos) / 8 -- starts at 0
local s = xgetr(self, k, "string")[1] or ""
if bytepos >= #s then return 0 end
local char = s:sub(bytepos+1, bytepos+1):byte()
return bit.band(bit.rshift(char, 7-bitpos), 1)
end
getrange = function(self, k, i1, i2)
k = chkarg(k)
i1, i2 = toint(i1), toint(i2)
assert(i1 and i2)
local x = xgetr(self, k, "string")
x = x[1] or ""
if i1 >= 0 then i1 = i1 + 1 end
if i2 >= 0 then i2 = i2 + 1 end
return x:sub(i1, i2)
end
local getset = function(self, k, v)
local r = get(self, k)
set(self, k, v)
return r
end
local incr = function(self, k)
return incrby(self, k, 1)
end
incrby = function(self, k, n)
k, n = chkarg(k), toint(n)
assert(n, "ERR value is not an integer or out of range")
local x = xgetw(self, k, "string")
local i = toint(x[1] or 0)
assert(i, "ERR value is not an integer or out of range")
i = i+n
assert(
(not overflows(i)),
"ERR increment or decrement would overflow"
)
x[1] = tostr(i)
return i
end
local incrbyfloat = function(self, k, n)
k, n = chkarg(k), tofloat(n)
assert(n, "ERR value is not a valid float")
local x = xgetw(self, k, "string")
local i = tofloat(x[1] or 0)
assert(i, "ERR value is not a valid float")
i = i+n
assert(
is_finite_number(i),
"ERR increment would produce NaN or Infinity"
)
x[1] = tostr(i)
return i
end
local mget = function(self, ...)
local arg, r = getargs(...), {}
for i=1,#arg do r[i] = get(self, arg[i]) end
return r
end
local mset = function(self, ...)
local argmap = getargs_as_map(...)
for k,v in pairs(argmap) do set(self, k, v) end
return true
end
local msetnx = function(self, ...)
local argmap = getargs_as_map(...)
for k,_ in pairs(argmap) do
if self.data[k] then return false end
end
for k,v in pairs(argmap) do set(self, k, v) end
return true
end
set = function(self, k, v)
self.data[k] = {ktype = "string", value = {v}}
return true
end
local setbit = function(self, k, offset, b)
k = chkarg(k)
offset, b = toint(offset), toint(b)
assert(
(offset >= 0),
"ERR bit offset is not an integer or out of range"
)
assert(
(b == 0) or (b == 1),
"ERR bit is not an integer or out of range"
)
local bitpos = offset % 8 -- starts at 0
local bytepos = (offset - bitpos) / 8 -- starts at 0
local s = xgetr(self, k, "string")[1] or ""
local pad = {s}
for i=2,bytepos+2-#s do pad[i] = "\0" end
s = table.concat(pad)
assert(#s >= bytepos+1)
local before = s:sub(1, bytepos)
local char = s:sub(bytepos+1, bytepos+1):byte()
local after = s:sub(bytepos+2, -1)
local old = bit.band(bit.rshift(char, 7-bitpos), 1)
if b == 1 then
char = bit.bor(bit.lshift(1, 7-bitpos), char)
else
char = bit.band(bit.bnot(bit.lshift(1, 7-bitpos)), char)
end
local r = before .. string.char(char) .. after
set(self, k, r)
return old
end
local setnx = function(self, k, v)
if self.data[k] then
return false
else
return set(self, k, v)
end
end
local setrange = function(self, k, i, s)
local k, s = chkargs(2, k, s)
i = toint(i)
assert(i and (i >= 0))
local x = xgetw(self, k, "string")
local y = x[1] or ""
local ly, ls = #y, #s
if i > ly then -- zero padding
local t = {}
for i=1, i-ly do t[i] = "\0" end
y = y .. table.concat(t) .. s
else
y = y:sub(1, i) .. s .. y:sub(i+ls+1, ly)
end
x[1] = y
return #y
end
local strlen = function(self, k)
local x = xgetr(self, k, "string")
return x[1] and #x[1] or 0
end
-- hashes
local hdel = function(self, k, ...)
k = chkarg(k)
local arg = getargs(...)
local r = 0
local x = xgetw(self, k, "hash")
for i=1,#arg do
if x[arg[i]] then r = r + 1 end
x[arg[i]] = nil
end
cleanup(self, k)
return r
end
local hget
local hexists = function(self, k, k2)
return not not hget(self, k, k2)
end
hget = function(self, k, k2)
local x = xgetr(self, k, "hash")
return x[k2]
end
local hgetall = function(self, k)
local x = xgetr(self, k, "hash")
local r = {}
for _k,v in pairs(x) do r[_k] = v end
return r
end
local hincrby = function(self, k, k2, n)
k, k2, n = chkarg(k), chkarg(k2), toint(n)
assert(n, "ERR value is not an integer or out of range")
assert(type(n) == "number")
local x = xgetw(self, k, "hash")
local i = toint(x[k2] or 0)
assert(i, "ERR value is not an integer or out of range")
i = i+n
assert(
(not overflows(i)),
"ERR increment or decrement would overflow"
)
x[k2] = tostr(i)
return i
end
local hincrbyfloat = function(self, k, k2, n)
k, k2, n = chkarg(k), chkarg(k2), tofloat(n)
assert(n, "ERR value is not a valid float")
local x = xgetw(self, k, "hash")
local i = tofloat(x[k2] or 0)
assert(i, "ERR value is not a valid float")
i = i+n
assert(
is_finite_number(i),
"ERR increment would produce NaN or Infinity"
)
x[k2] = tostr(i)
return i
end
local hkeys = function(self, k)
local x = xgetr(self, k, "hash")
local r = {}
for _k,_ in pairs(x) do r[#r+1] = _k end
return r
end
local hlen = function(self, k)
local x = xgetr(self, k, "hash")
return nkeys(x)
end
local hmget = function(self, k, k2s)
k = chkarg(k)
assert((type(k2s) == "table"))
local r = {}
local x = xgetr(self, k, "hash")
for i=1,#k2s do r[i] = x[chkarg(k2s[i])] end
return r
end
local hmset = function(self, k, ...)
k = chkarg(k)
local arg = {...}
if type(arg[1]) == "table" then
assert(#arg == 1)
local x = xgetw(self, k, "hash")
for _k,v in pairs(arg[1]) do x[chkarg(_k)] = chkarg(v) end
else
assert(#arg % 2 == 0)
local x = xgetw(self, k, "hash")
local t = getargs(...)
for i=1,#t,2 do x[t[i]] = t[i+1] end
end
return true
end
local hset = function(self, k, k2, v)
local x = xgetw(self, k, "hash")
local r = not x[k2]
x[k2] = v
return r
end
local hsetnx = function(self, k, k2, v)
local x = xgetw(self, k, "hash")
if x[k2] == nil then
x[k2] = v
return true
else
return false
end
end
local hvals = function(self, k)
local x = xgetr(self, k, "hash")
local r = {}
for _,v in pairs(x) do r[#r+1] = v end
return r
end
-- lists (head = left, tail = right)
local _l_real_i = function(x, i)
if i < 0 then
return x.tail+i+1
else
return x.head+i+1
end
end
local _l_len = function(x)
return x.tail - x.head
end
local _block_for = function(self, timeout)
if timeout > 0 then
local sleep = self.sleep or default_sleep
if type(sleep) == "function" then
sleep(timeout)
else
error("sleep function unavailable", 0)
end
else
error("operation would block", 0)
end
end
local rpoplpush
local blpop = function(self, ...)
local arg = {...}
local timeout = toint(arg[#arg])
arg[#arg] = nil
local vs = getargs(...)
local x, l, k, v
for i=1,#vs do
k = vs[i]
x = xgetw(self, k, "list")
l = _l_len(x)
if l > 0 then
v = x[x.head+1]
if l > 1 then
x.head = x.head + 1
x[x.head] = nil
else self.data[k] = nil end
return {k, v}
else self.data[k] = nil end
end
_block_for(self, timeout)
end
local brpop = function(self, ...)
local arg = {...}
local timeout = toint(arg[#arg])
arg[#arg] = nil
local vs = getargs(...)
local x, l, k, v
for i=1,#vs do
k = vs[i]
x = xgetw(self, k, "list")
l = _l_len(x)
if l > 0 then
v = x[x.tail]
if l > 1 then
x[x.tail] = nil
x.tail = x.tail - 1
else self.data[k] = nil end
return {k, v}
else self.data[k] = nil end
end
_block_for(self, timeout)
end
local brpoplpush = function(self, k1, k2, timeout)
k1, k2 = chkargs(2, k1, k2)
timeout = toint(timeout)
if not self.data[k1] then _block_for(self, timeout) end
return rpoplpush(self, k1, k2)
end
local lindex = function(self, k, i)
k = chkarg(k)
i = assert(toint(i))
local x = xgetr(self, k, "list")
return x[_l_real_i(x, i)]
end
local linsert = function(self, k, mode, pivot, v)
mode = mode:lower()
assert((mode == "before") or (mode == "after"))
if not self.data[k] then return 0 end
local x = xgetw(self, k, "list")
local p = nil
for i=x.head+1, x.tail do
if x[i] == pivot then
p = i
break
end
end
if not p then return -1 end
if mode == "after" then
for i=x.head+1, p do x[i-1] = x[i] end
x.head = x.head - 1
else
for i=x.tail, p, -1 do x[i+1] = x[i] end
x.tail = x.tail + 1
end
x[p] = v
return _l_len(x)
end
local llen = function(self, k)
local x = xgetr(self, k, "list")
return _l_len(x)
end
local lpop = function(self, k)
local x = xgetw(self, k, "list")
local l, r = _l_len(x), x[x.head+1]
if l > 1 then
x.head = x.head + 1
x[x.head] = nil
else self.data[k] = nil end
return r
end
local lpush = function(self, k, ...)
local vs = getargs(...)
local x = xgetw(self, k, "list")
for i=1,#vs do
x[x.head] = vs[i]
x.head = x.head - 1
end
return _l_len(x)
end
local lpushx = function(self, k, v)
if not self.data[k] then return 0 end
local x = xgetw(self, k, "list")
x[x.head] = v
x.head = x.head - 1
return _l_len(x)
end
local lrange = function(self, k, i1, i2)
k = chkarg(k)
i1, i2 = toint(i1), toint(i2)
assert(i1 and i2)
local x, r = xgetr(self, k, "list"), {}
i1 = math.max(_l_real_i(x, i1), x.head+1)
i2 = math.min(_l_real_i(x, i2), x.tail)
for i=i1,i2 do r[#r+1] = x[i] end
return r
end
local _lrem_i = function(x, p)
for i=p,x.tail do
x[i] = x[i+1]
end
x.tail = x.tail - 1
end
local _lrem_l = function(x, v, s)
assert(v)
if not s then s = x.head+1 end
for i=s,x.tail do
if x[i] == v then
_lrem_i(x, i)
return i
end
end
return false
end
local _lrem_r = function(x, v, s)
assert(v)
if not s then s = x.tail end
for i=s,x.head+1,-1 do
if x[i] == v then
_lrem_i(x, i)
return i
end
end
return false
end
local lrem = function(self, k, count, v)
k, v = chkarg(k), chkarg(v)
count = assert(toint(count))
if not self.data[k] then return 0 end
local x = xgetw(self, k, "list")
local n, last = 0, nil
local op = (count < 0) and _lrem_r or _lrem_l
local limited = (count ~= 0)
count = math.abs(count)
while true do
last = op(x, v, last)
if last then
n = n+1
if limited then
count = count - 1
if count == 0 then break end
end
else break end
end
return n
end
local lset = function(self, k, i, v)
k, v = chkarg(k), chkarg(v)
i = assert(toint(i))
if not self.data[k] then
error("ERR no such key")
end
local x = xgetw(self, k, "list")
local l = _l_len(x)
if i >= l or i < -l then
error("ERR index out of range")
end
x[_l_real_i(x, i)] = v
return true
end
local ltrim = function(self, k, i1, i2)
k = chkarg(k)
i1, i2 = toint(i1), toint(i2)
assert(i1 and i2)
local x = xgetw(self, k, "list")
i1, i2 = _l_real_i(x, i1), _l_real_i(x, i2)
for i=x.head+1,i1-1 do x[i] = nil end
for i=i2+1,x.tail do x[i] = nil end
x.head = math.max(i1-1, x.head)
x.tail = math.min(i2, x.tail)
assert(
(x[x.head] == nil) and
(x[x.tail+1] == nil)
)
cleanup(self, k)
return true
end
local rpop = function(self, k)
local x = xgetw(self, k, "list")
local l, r = _l_len(x), x[x.tail]
if l > 1 then
x[x.tail] = nil
x.tail = x.tail - 1
else self.data[k] = nil end
return r
end
rpoplpush = function(self, k1, k2)
local v = rpop(self, k1)
if not v then return nil end
lpush(self, k2, v)
return v
end
local rpush = function(self, k, ...)
local vs = getargs(...)
local x = xgetw(self, k, "list")
for i=1,#vs do
x.tail = x.tail + 1
x[x.tail] = vs[i]
end
return _l_len(x)
end
local rpushx = function(self, k, v)
if not self.data[k] then return 0 end
local x = xgetw(self, k, "list")
x.tail = x.tail + 1
x[x.tail] = v
return _l_len(x)
end
-- sets
local sadd = function(self, k, ...)
k = chkarg(k)
local arg = getargs(...)
local x, r = xgetw(self, k, "set"), 0
for i=1,#arg do
if not x[arg[i]] then
x[arg[i]] = true
r = r + 1
end
end
return r
end
local scard = function(self, k)
local x = xgetr(self, k, "set")
return nkeys(x)
end
local _sdiff = function(self, k, ...)
k = chkarg(k)
local arg = getargs(...)
local x = xgetr(self, k, "set")
local r = {}
for v,_ in pairs(x) do r[v] = true end
for i=1,#arg do
x = xgetr(self, arg[i], "set")
for v,_ in pairs(x) do r[v] = nil end
end
return r
end
local sdiff = function(self, k, ...)
return lset_to_list(_sdiff(self, k, ...))
end
local sdiffstore = function(self, k2, k, ...)
k2 = chkarg(k2)
local x = _sdiff(self, k, ...)
self.data[k2] = {ktype = "set", value = x}
return nkeys(x)
end
local _sinter = function(self, k, ...)
k = chkarg(k)
local arg = getargs(...)
local x = xgetr(self, k, "set")
local r = {}
local y
for v,_ in pairs(x) do
r[v] = true
for i=1,#arg do
y = xgetr(self, arg[i], "set")
if not y[v] then r[v] = nil; break end
end
end
return r
end
local sinter = function(self, k, ...)
return lset_to_list(_sinter(self, k, ...))
end
local sinterstore = function(self, k2, k, ...)
k2 = chkarg(k2)
local x = _sinter(self, k, ...)
self.data[k2] = {ktype = "set", value = x}
return nkeys(x)
end
local sismember = function(self, k, v)
local x = xgetr(self, k, "set")
return not not x[v]
end
local smembers = function(self, k)
local x = xgetr(self, k, "set")
return lset_to_list(x)
end
local smove = function(self, k, k2, v)
local x = xgetr(self, k, "set")
if x[v] then
local y = xgetw(self, k2, "set")
x[v] = nil
y[v] = true
return true
else return false end
end
local spop = function(self, k)
local x, r = xgetw(self, k, "set"), nil
local l = lset_to_list(x)
local n = #l
if n > 0 then
r = l[math.random(1, n)]
x[r] = nil
end
cleanup(self, k)
return r
end
local srandmember = function(self, k, count)
k = chkarg(k)
local x = xgetr(self, k, "set")
local l = lset_to_list(x)
local n = #l
if not count then
if n > 0 then
return l[math.random(1, n)]
else return nil end
end
count = toint(count)
if (count == 0) or (n == 0) then return {} end
if count >= n then return l end
local r = {}
if count > 0 then -- distinct elements
for i=0,count-1 do
r[#r+1] = table.remove(l, math.random(1, n-i))
end
else -- allow repetition
for i=1,-count do
r[#r+1] = l[math.random(1, n)]
end
end
return r
end
local srem = function(self, k, ...)
k = chkarg(k)
local arg = getargs(...)
local x, r = xgetw(self, k, "set"), 0
for i=1,#arg do
if x[arg[i]] then
x[arg[i]] = nil
r = r + 1
end
end
cleanup(self, k)
return r
end
local _sunion = function(self, ...)
local arg = getargs(...)
local r = {}
local x
for i=1,#arg do
x = xgetr(self, arg[i], "set")
for v,_ in pairs(x) do r[v] = true end
end
return r
end
local sunion = function(self, k, ...)
return lset_to_list(_sunion(self, k, ...))
end
local sunionstore = function(self, k2, k, ...)
k2 = chkarg(k2)
local x = _sunion(self, k, ...)
self.data[k2] = {ktype = "set", value = x}
return nkeys(x)
end
-- zsets
local _z_p_mt = {
__eq = function(a, b)
if a.v == b.v then
assert(a.s == b.s)
return true
else return false end
end,
__lt = function(a, b)
if a.s == b.s then
return (a.v < b.v)
else
return (a.s < b.s)
end
end,
}
local _z_pair = function(s, v)
assert(
(type(s) == "number") and
(type(v) == "string")
)
local r = {s = s, v = v}
return setmetatable(r, _z_p_mt)
end
local _z_pairs = function(...)
local arg = {...}
assert((#arg > 0) and (#arg % 2 == 0))
local ps = {}
for i=1,#arg,2 do
ps[#ps+1] = _z_pair(
assert(tofloat(arg[i])),
chkarg(arg[i+1])
)
end
return ps
end
local _z_insert = function(x, ix, p)
assert(
(type(x) == "table") and
(type(ix) == "number") and
(type(p) == "table")
)
local l = x.list
table.insert(l, ix, p)
for i=ix+1,#l do
x.set[l[i].v] = x.set[l[i].v] + 1
end
x.set[p.v] = ix
end
local _z_remove = function(x, v)
if not x.set[v] then return false end
local l, ix = x.list, x.set[v]
assert(l[ix].v == v)
table.remove(l, ix)
for i=ix,#l do
x.set[l[i].v] = x.set[l[i].v] - 1
end
x.set[v] = nil
return true
end
local _z_remove_range = function(x, i1, i2)
local l = x.list
i2 = i2 or i1
assert(
(i1 > 0) and
(i2 >= i1) and
(i2 <= #l)
)
local ix, n = i1, i2-i1+1
for i=1,n do
x.set[l[ix].v] = nil
table.remove(l, ix)
end
for i=ix,#l do
x.set[l[i].v] = x.set[l[i].v] - n
end
return n
end
local _z_update = function(x, p)
local l = x.list
local found = _z_remove(x, p.v)
local ix = nil
for i=1,#l do
if l[i] > p then
ix = i; break
end
end
if not ix then ix = #l+1 end
_z_insert(x, ix, p)
return found
end
local _z_coherence = function(x)
local l, s = x.list, x.set
local found, n = {}, 0
for val,pos in pairs(s) do
if found[pos] then return false end
found[pos] = true
n = n + 1
if not (l[pos] and (l[pos].v == val)) then
return false
end
end
if #l ~= n then return false end
for i=1, n-1 do
if l[i].s > l[i+1].s then return false end
end
return true
end
local _z_normrange = function(l, i1, i2)
i1, i2 = assert(toint(i1)), assert(toint(i2))
if i1 < 0 then i1 = #l+i1 end
if i2 < 0 then i2 = #l+i2 end
i1, i2 = math.max(i1+1, 1), i2+1
if (i2 < i1) or (i1 > #l) then return nil end
i2 = math.min(i2, #l)
return i1, i2
end
local _zrbs_opts = function(...)
local arg = {...}
if #arg == 0 then return {} end
local ix, opts = 1, {}
while type(arg[ix]) == "string" do
if arg[ix] == "withscores" then
opts.withscores = true
ix = ix + 1
elseif arg[ix] == "limit" then
opts.limit = {
offset = assert(toint(arg[ix+1])),
count = assert(toint(arg[ix+2])),
}
ix = ix + 3
else error("input") end
end
if type(arg[ix]) == "table" then
local _o = arg[ix]
opts.withscores = opts.withscores or _o.withscores
if _o.limit then
opts.limit = {
offset = assert(toint(_o.limit.offset or _o.limit[1])),
count = assert(toint(_o.limit.count or _o.limit[2])),
}
end
ix = ix + 1
end
assert(arg[ix] == nil)
if opts.limit then
assert(
(opts.limit.count >= 0) and
(opts.limit.offset >= 0)
)
end
return opts
end
local _z_store_params = function(dest, numkeys, ...)
dest = chkarg(dest)
numkeys = assert(toint(numkeys))
assert(numkeys > 0)
local arg = {...}
assert(#arg >= numkeys)
local ks = {}
for i=1, numkeys do ks[i] = chkarg(arg[i]) end
local ix, opts = numkeys+1,{}
while type(arg[ix]) == "string" do
if arg[ix] == "weights" then
opts.weights = {}
ix = ix + 1
for i=1, numkeys do
opts.weights[i] = assert(toint(arg[ix]))
ix = ix + 1
end
elseif arg[ix] == "aggregate" then
opts.aggregate = assert(chkarg(arg[ix+1]))
ix = ix + 2
else error("input") end
end
if type(arg[ix]) == "table" then
local _o = arg[ix]
opts.weights = opts.weights or _o.weights
opts.aggregate = opts.aggregate or _o.aggregate
ix = ix + 1
end
assert(arg[ix] == nil)
if opts.aggregate then
assert(
(opts.aggregate == "sum") or
(opts.aggregate == "min") or
(opts.aggregate == "max")
)
else opts.aggregate = "sum" end
if opts.weights then
assert(#opts.weights == numkeys)
for i=1,#opts.weights do
assert(type(opts.weights[i]) == "number")
end
else
opts.weights = {}
for i=1, numkeys do opts.weights[i] = 1 end
end
opts.keys = ks
opts.dest = dest
return opts
end
local _zrbs_limits = function(x, s1, s2, descending)
local s1_incl, s2_incl = true, true
if s1:sub(1, 1) == "(" then
s1, s1_incl = s1:sub(2, -1), false
end
s1 = assert(tofloat(s1))
if s2:sub(1, 1) == "(" then
s2, s2_incl = s2:sub(2, -1), false
end
s2 = assert(tofloat(s2))
if descending then
s1, s2 = s2, s1
s1_incl, s2_incl = s2_incl, s1_incl
end
if s2 < s1 then return nil end
local l = x.list
local i1, i2
local fst, lst = l[1].s, l[#l].s
if (fst > s2) or ((not s2_incl) and (fst == s2)) then return nil end
if (lst < s1) or ((not s1_incl) and (lst == s1)) then return nil end
if (fst > s1) or (s1_incl and (fst == s1)) then i1 = 1 end
if (lst < s2) or (s2_incl and (lst == s2)) then i2 = #l end
for i=1,#l do
if (i1 and i2) then break end
if (not i1) then
if l[i].s > s1 then i1 = i end
if s1_incl and l[i].s == s1 then i1 = i end
end
if (not i2) then
if l[i].s > s2 then i2 = i-1 end
if (not s2_incl) and l[i].s == s2 then i2 = i-1 end
end
end
assert(i1 and i2)
if descending then
return #l-i2, #l-i1
else
return i1-1, i2-1
end
end
local dbg_zcoherence = function(self, k)
local x = xgetr(self, k, "zset")
return _z_coherence(x)
end
local zadd = function(self, k, ...)
k = chkarg(k)
local ps = _z_pairs(...)
local x = xgetw(self, k, "zset")
local n = 0
for i=1,#ps do
if not _z_update(x, ps[i]) then n = n+1 end
end
return n
end
local zcard = function(self, k)
local x = xgetr(self, k, "zset")
return #x.list
end
local zcount = function(self, k, s1, s2)
local x = xgetr(self, k, "zset")
local i1, i2 = _zrbs_limits(x, s1, s2, false)
if not (i1 and i2) then return 0 end
assert(i2 >= i1)
return i2 - i1 + 1
end
local zincrby = function(self, k, n, v)
k,v = chkargs(2, k, v)
n = assert(tofloat(n))
local x = xgetw(self, k, "zset")
local p = x.list[x.set[v]]
local s = p and (p.s + n) or n
_z_update(x, _z_pair(s, v))
return s
end
local zinterstore = function(self, ...)
local params = _z_store_params(...)
local x = xdefv("zset")
local aggregate
if params.aggregate == "sum" then
aggregate = function(x, y) return x+y end
elseif params.aggregate == "min" then
aggregate = math.min
elseif params.aggregate == "max" then
aggregate = math.max
else error() end
local y = xgetr(self, params.keys[1], "zset")
local p1, p2
for j=1,#y.list do
p1 = _z_pair(y.list[j].s, y.list[j].v)
_z_update(x, p1)
end
for i=2,#params.keys do
y = xgetr(self, params.keys[i], "zset")
local to_remove, to_update = {}, {}
for j=1,#x.list do
p1 = x.list[j]
if y.set[p1.v] then
p2 = _z_pair(
aggregate(
p1.s,
params.weights[i] * y.list[y.set[p1.v]].s
),
p1.v
)
to_update[#to_update+1] = p2
else
to_remove[#to_remove+1] = p1.v
end
end
for j=1,#to_remove do _z_remove(x, to_remove[j]) end
for j=1,#to_update do _z_update(x, to_update[j]) end
end
local r = #x.list
if r > 0 then
self.data[params.dest] = {ktype = "zset", value = x}
end
return r
end
local _zranger = function(descending)
return function(self, k, i1, i2, opts)
k = chkarg(k)
local withscores = false
if type(opts) == "table" then
withscores = opts.withscores
elseif type(opts) == "string" then
assert(opts:lower() == "withscores")
withscores = true
else assert(opts == nil) end
local x = xgetr(self, k, "zset")
local l = x.list
i1, i2 = _z_normrange(l, i1, i2)
if not i1 then return {} end
local inc = 1
if descending then
i1 = #l - i1 + 1
i2 = #l - i2 + 1
inc = -1
end
local r = {}
if withscores then
for i=i1, i2, inc do r[#r+1] = {l[i].v, l[i].s} end
else
for i=i1, i2, inc do r[#r+1] = l[i].v end
end
return r
end
end
local zrange = _zranger(false)
local zrevrange = _zranger(true)
local _zrangerbyscore = function(descending)
return function(self, k, s1, s2, ...)
k, s1, s2 = chkargs(3, k, s1, s2)
local opts = _zrbs_opts(...)
local x = xgetr(self, k, "zset")
local i1, i2 = _zrbs_limits(x, s1, s2, descending)
if not (i1 and i2) then return {} end
if opts.limit then
if opts.limit.count == 0 then return {} end
i1 = i1 + opts.limit.offset
if i1 > i2 then return {} end
i2 = math.min(i2, i1+opts.limit.count-1)
end
if descending then
return zrevrange(self, k, i1, i2, opts)
else
return zrange(self, k, i1, i2, opts)
end
end
end
local zrangebyscore = _zrangerbyscore(false)
local zrevrangebyscore = _zrangerbyscore(true)
local zrank = function(self, k, v)
local x = xgetr(self, k, "zset")
local r = x.set[v]
if r then
return r-1
else return nil end
end
local zrem = function(self, k, ...)
k = chkarg(k)
local arg = getargs(...)
local x, r = xgetw(self, k, "zset"), 0
for i=1,#arg do
if _z_remove(x, arg[i]) then r = r + 1 end
end
cleanup(self, k)
return r
end
local zremrangebyrank = function(self, k, i1, i2)
k = chkarg(k)
local x = xgetw(self, k, "zset")
i1, i2 = _z_normrange(x.list, i1, i2)
if not i1 then
cleanup(self, k)
return 0
end
local n = _z_remove_range(x, i1, i2)
cleanup(self, k)
return n
end
local zremrangebyscore = function(self, k, s1, s2)
local x = xgetr(self, k, "zset")
local i1, i2 = _zrbs_limits(x, s1, s2, false)
if not (i1 and i2) then return 0 end
assert(i2 >= i1)
return zremrangebyrank(self, k, i1, i2)
end
local zrevrank = function(self, k, v)
local x = xgetr(self, k, "zset")
local r = x.set[v]
if r then
return #x.list-r
else return nil end
end
local zscore = function(self, k, v)
local x = xgetr(self, k, "zset")
local p = x.list[x.set[v]]
if p then
return p.s
else return nil end
end
local zunionstore = function(self, ...)
local params = _z_store_params(...)
local x = xdefv("zset")
local default_score, aggregate
if params.aggregate == "sum" then
default_score = 0
aggregate = function(x, y) return x+y end
elseif params.aggregate == "min" then
default_score = math.huge
aggregate = math.min
elseif params.aggregate == "max" then
default_score = -math.huge
aggregate = math.max
else error() end
local y, p1, p2
for i=1,#params.keys do
y = xgetr(self, params.keys[i], "zset")
for j=1,#y.list do
p1 = y.list[j]
p2 = _z_pair(
aggregate(
params.weights[i] * p1.s,
x.set[p1.v] and x.list[x.set[p1.v]].s or default_score
),
p1.v
)
_z_update(x, p2)
end
end
local r = #x.list
if r > 0 then
self.data[params.dest] = {ktype = "zset", value = x}
end
return r
end
-- connection
local echo = function(self, v)
return v
end
local ping = function(self)
return true
end
-- server
local flushdb = function(self)
self.data = {}
return true
end
--- Class
local methods = {
-- keys
del = del, -- (...) -> #removed
exists = chkargs_wrap(exists, 1), -- (k) -> exists?
keys = keys, -- (pattern) -> list of keys
["type"] = chkargs_wrap(_type, 1), -- (k) -> [string|list|set|zset|hash|none]
randomkey = randomkey, -- () -> [k|nil]
rename = chkargs_wrap(rename, 2), -- (k,k2) -> true
renamenx = chkargs_wrap(renamenx, 2), -- (k,k2) -> ! existed? k2
-- strings
append = chkargs_wrap(append, 2), -- (k,v) -> #new
bitcount = bitcount, -- (k,[start,end]) -> n
bitop = bitop, -- ([and|or|xor|not],k,...)
decr = chkargs_wrap(decr, 1), -- (k) -> new
decrby = decrby, -- (k,n) -> new
get = chkargs_wrap(get, 1), -- (k) -> [v|nil]
getbit = getbit, -- (k,offset) -> b
getrange = getrange, -- (k,start,end) -> string
getset = chkargs_wrap(getset, 2), -- (k,v) -> [oldv|nil]
incr = chkargs_wrap(incr, 1), -- (k) -> new
incrby = incrby, -- (k,n) -> new
incrbyfloat = incrbyfloat, -- (k,n) -> new
mget = mget, -- (k1,...) -> {v1,...}
mset = mset, -- (k1,v1,...) -> true
msetnx = msetnx, -- (k1,v1,...) -> worked? (i.e. !existed? any k)
set = chkargs_wrap(set, 2), -- (k,v) -> true
setbit = setbit, -- (k,offset,b) -> old
setnx = chkargs_wrap(setnx, 2), -- (k,v) -> worked? (i.e. !existed?)
setrange = setrange, -- (k,offset,val) -> #new
strlen = chkargs_wrap(strlen, 1), -- (k) -> [#v|0]
-- hashes
hdel = hdel, -- (k,sk1,...) -> #removed
hexists = chkargs_wrap(hexists, 2), -- (k,sk) -> exists?
hget = chkargs_wrap(hget,2), -- (k,sk) -> v
hgetall = chkargs_wrap(hgetall, 1), -- (k) -> map
hincrby = hincrby, -- (k,sk,n) -> new
hincrbyfloat = hincrbyfloat, -- (k,sk,n) -> new
hkeys = chkargs_wrap(hkeys, 1), -- (k) -> keys
hlen = chkargs_wrap(hlen, 1), -- (k) -> [#sk|0]
hmget = hmget, -- (k,{sk1,...}) -> {v1,...}
hmset = hmset, -- (k,{sk1=v1,...}) -> true
hset = chkargs_wrap(hset, 3), -- (k,sk1,v1) -> !existed?
hsetnx = chkargs_wrap(hsetnx, 3), -- (k,sk1,v1) -> worked? (i.e. !existed?)
hvals = chkargs_wrap(hvals, 1), -- (k) -> values
-- lists
blpop = blpop, -- (k1,...) -> k,v
brpop = brpop, -- (k1,...) -> k,v
brpoplpush = brpoplpush, -- (k1,k2,timeout) -> v
lindex = lindex, -- (k,i) -> v
linsert = chkargs_wrap(linsert, 4), -- (k,mode,pivot,v) -> #list (after)
llen = chkargs_wrap(llen, 1), -- (k) -> #list
lpop = chkargs_wrap(lpop, 1), -- (k) -> v
lpush = lpush, -- (k,v1,...) -> #list (after)
lpushx = chkargs_wrap(lpushx, 2), -- (k,v) -> #list (after)
lrange = lrange, -- (k,start,stop) -> list
lrem = lrem, -- (k,count,v) -> #removed
lset = lset, -- (k,i,v) -> true
ltrim = ltrim, -- (k,start,stop) -> true
rpop = chkargs_wrap(rpop, 1), -- (k) -> v
rpoplpush = chkargs_wrap(rpoplpush, 2), -- (k1,k2) -> v
rpush = rpush, -- (k,v1,...) -> #list (after)
rpushx = chkargs_wrap(rpushx, 2), -- (k,v) -> #list (after)
-- sets
sadd = sadd, -- (k,v1,...) -> #added
scard = chkargs_wrap(scard, 1), -- (k) -> [n|0]
sdiff = sdiff, -- (k1,...) -> set (of elements in k1 & not in any of ...)
sdiffstore = sdiffstore, -- (k0,k1,...) -> #set at k0
sinter = sinter, -- (k1,...) -> set
sinterstore = sinterstore, -- (k0,k1,...) -> #set at k0
sismember = chkargs_wrap(sismember, 2), -- (k,v) -> member?
smembers = chkargs_wrap(smembers, 1), -- (k) -> set
smove = chkargs_wrap(smove, 3), -- (k1,k2,v) -> moved? (i.e. !member? k1)
spop = chkargs_wrap(spop, 1), -- (k) -> [v|nil]
srandmember = srandmember, -- (k,[count]) -> v|[v1,v2,...]
srem = srem, -- (k,v1,...) -> #removed
sunion = sunion, -- (k1,...) -> set
sunionstore = sunionstore, -- (k0,k1,...) -> #set at k0
-- zsets
zadd = zadd, -- (k,score,member,[score,member,...])
zcard = chkargs_wrap(zcard, 1), -- (k) -> n
zcount = chkargs_wrap(zcount, 3), -- (k,min,max) -> count
zincrby = zincrby, -- (k,score,v) -> score
zinterstore = zinterstore, -- (k,numkeys,k1,...,[opts]) -> card
zrange = zrange, -- (k,start,stop,[opts]) -> depends on opts
zrangebyscore = zrangebyscore, -- (k,min,max,[opts]) -> depends on opts
zrank = chkargs_wrap(zrank, 2), -- (k,v) -> rank
zrem = zrem, -- (k,v1,...) -> #removed
zremrangebyrank = zremrangebyrank, -- (k,start,stop) -> #removed
zremrangebyscore = chkargs_wrap(zremrangebyscore, 3), -- (k,min,max) -> #removed
zrevrange = zrevrange, -- (k,start,stop,[opts]) -> depends on opts
zrevrangebyscore = zrevrangebyscore, -- (k,min,max,[opts]) -> depends on opts
zrevrank = chkargs_wrap(zrevrank, 2), -- (k,v) -> rank
zscore = chkargs_wrap(zscore, 2), -- (k,v) -> score
zunionstore = zunionstore, -- (k,numkeys,k1,...,[opts]) -> card
-- connection
echo = chkargs_wrap(echo, 1), -- (v) -> v
ping = ping, -- () -> true
-- server
flushall = flushdb, -- () -> true
flushdb = flushdb, -- () -> true
-- debug
dbg_zcoherence = dbg_zcoherence,
}
local new = function()
local r = {data = {}}
return setmetatable(r,{__index = methods})
end
return {
new = new,
}
-- @PequeRobotCH
-- http://pequerobot.com
| botsazn/Management-Group | libs/fakeredis.lua | Lua | gpl-3.0 | 40,447 | [
30522,
2334,
4895,
23947,
1027,
2795,
1012,
4895,
23947,
2030,
4895,
23947,
1011,
1011,
1011,
2978,
3136,
2334,
7929,
1010,
2978,
2065,
1035,
2544,
1027,
1027,
1000,
11320,
2050,
1019,
1012,
1017,
1000,
2059,
2978,
1027,
1006,
7170,
1031,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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... |
/*
* cocos2d-x http://www.cocos2d-x.org
*
* Copyright (c) 2010-2014 - cocos2d-x community
* Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd.
*
* Portions Copyright (c) Microsoft Open Technologies, Inc.
* All Rights Reserved
*
* 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.
*/
#include "App.xaml.h"
#include "OpenGLESPage.xaml.h"
using namespace CocosAppWinRT;
using namespace cocos2d;
using namespace Platform;
using namespace Concurrency;
using namespace Windows::Foundation;
using namespace Windows::Graphics::Display;
using namespace Windows::System::Threading;
using namespace Windows::UI::Core;
using namespace Windows::UI::Input;
using namespace Windows::UI::Xaml;
using namespace Windows::UI::Xaml::Controls;
using namespace Windows::UI::Xaml::Controls::Primitives;
using namespace Windows::UI::Xaml::Data;
using namespace Windows::UI::Xaml::Input;
using namespace Windows::UI::Xaml::Media;
using namespace Windows::UI::Xaml::Navigation;
#if (WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP) || _MSC_VER >= 1900
using namespace Windows::Phone::UI::Input;
#endif
OpenGLESPage::OpenGLESPage() :
OpenGLESPage(nullptr)
{
}
OpenGLESPage::OpenGLESPage(OpenGLES* openGLES) :
mOpenGLES(openGLES),
mRenderSurface(EGL_NO_SURFACE),
mCoreInput(nullptr),
mDpi(0.0f),
mDeviceLost(false),
mCursorVisible(true),
mVisible(false),
mOrientation(DisplayOrientations::Landscape)
{
InitializeComponent();
Windows::UI::Core::CoreWindow^ window = Windows::UI::Xaml::Window::Current->CoreWindow;
window->VisibilityChanged +=
ref new Windows::Foundation::TypedEventHandler<Windows::UI::Core::CoreWindow^, Windows::UI::Core::VisibilityChangedEventArgs^>(this, &OpenGLESPage::OnVisibilityChanged);
window->KeyDown += ref new TypedEventHandler<CoreWindow^, KeyEventArgs^>(this, &OpenGLESPage::OnKeyPressed);
window->KeyUp += ref new TypedEventHandler<CoreWindow^, KeyEventArgs^>(this, &OpenGLESPage::OnKeyReleased);
window->CharacterReceived += ref new TypedEventHandler<CoreWindow^, CharacterReceivedEventArgs^>(this, &OpenGLESPage::OnCharacterReceived);
DisplayInformation^ currentDisplayInformation = DisplayInformation::GetForCurrentView();
currentDisplayInformation->OrientationChanged +=
ref new TypedEventHandler<DisplayInformation^, Object^>(this, &OpenGLESPage::OnOrientationChanged);
mOrientation = currentDisplayInformation->CurrentOrientation;
this->Loaded +=
ref new Windows::UI::Xaml::RoutedEventHandler(this, &OpenGLESPage::OnPageLoaded);
#if _MSC_VER >= 1900
if (Windows::Foundation::Metadata::ApiInformation::IsTypePresent("Windows.UI.ViewManagement.StatusBar"))
{
Windows::UI::ViewManagement::StatusBar::GetForCurrentView()->HideAsync();
}
if (Windows::Foundation::Metadata::ApiInformation::IsTypePresent("Windows.Phone.UI.Input.HardwareButtons"))
{
HardwareButtons::BackPressed += ref new EventHandler<BackPressedEventArgs^>(this, &OpenGLESPage::OnBackButtonPressed);
}
#else
#if (WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP)
Windows::UI::ViewManagement::StatusBar::GetForCurrentView()->HideAsync();
HardwareButtons::BackPressed += ref new EventHandler<BackPressedEventArgs^>(this, &OpenGLESPage::OnBackButtonPressed);
#else
// Disable all pointer visual feedback for better performance when touching.
// This is not supported on Windows Phone applications.
auto pointerVisualizationSettings = Windows::UI::Input::PointerVisualizationSettings::GetForCurrentView();
pointerVisualizationSettings->IsContactFeedbackEnabled = false;
pointerVisualizationSettings->IsBarrelButtonFeedbackEnabled = false;
#endif
#endif
CreateInput();
}
void OpenGLESPage::CreateInput()
{
// Register our SwapChainPanel to get independent input pointer events
auto workItemHandler = ref new WorkItemHandler([this](IAsyncAction ^)
{
// The CoreIndependentInputSource will raise pointer events for the specified device types on whichever thread it's created on.
mCoreInput = swapChainPanel->CreateCoreIndependentInputSource(
Windows::UI::Core::CoreInputDeviceTypes::Mouse |
Windows::UI::Core::CoreInputDeviceTypes::Touch |
Windows::UI::Core::CoreInputDeviceTypes::Pen
);
// Register for pointer events, which will be raised on the background thread.
mCoreInput->PointerPressed += ref new TypedEventHandler<Object^, PointerEventArgs^>(this, &OpenGLESPage::OnPointerPressed);
mCoreInput->PointerMoved += ref new TypedEventHandler<Object^, PointerEventArgs^>(this, &OpenGLESPage::OnPointerMoved);
mCoreInput->PointerReleased += ref new TypedEventHandler<Object^, PointerEventArgs^>(this, &OpenGLESPage::OnPointerReleased);
mCoreInput->PointerWheelChanged += ref new TypedEventHandler<Object^, PointerEventArgs^>(this, &OpenGLESPage::OnPointerWheelChanged);
if (GLViewImpl::sharedOpenGLView() && !GLViewImpl::sharedOpenGLView()->isCursorVisible())
{
mCoreInput->PointerCursor = nullptr;
}
// Begin processing input messages as they're delivered.
mCoreInput->Dispatcher->ProcessEvents(CoreProcessEventsOption::ProcessUntilQuit);
});
// Run task on a dedicated high priority background thread.
mInputLoopWorker = ThreadPool::RunAsync(workItemHandler, WorkItemPriority::High, WorkItemOptions::TimeSliced);
}
OpenGLESPage::~OpenGLESPage()
{
StopRenderLoop();
DestroyRenderSurface();
}
void OpenGLESPage::OnPageLoaded(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e)
{
// The SwapChainPanel has been created and arranged in the page layout, so EGL can be initialized.
CreateRenderSurface();
StartRenderLoop();
mVisible = true;
}
void OpenGLESPage::CreateRenderSurface()
{
if (mOpenGLES && mRenderSurface == EGL_NO_SURFACE)
{
// The app can configure the SwapChainPanel which may boost performance.
// By default, this template uses the default configuration.
mRenderSurface = mOpenGLES->CreateSurface(swapChainPanel, nullptr, nullptr);
// You can configure the SwapChainPanel to render at a lower resolution and be scaled up to
// the swapchain panel size. This scaling is often free on mobile hardware.
//
// One way to configure the SwapChainPanel is to specify precisely which resolution it should render at.
// Size customRenderSurfaceSize = Size(800, 600);
// mRenderSurface = mOpenGLES->CreateSurface(swapChainPanel, &customRenderSurfaceSize, nullptr);
//
// Another way is to tell the SwapChainPanel to render at a certain scale factor compared to its size.
// e.g. if the SwapChainPanel is 1920x1280 then setting a factor of 0.5f will make the app render at 960x640
// float customResolutionScale = 0.5f;
// mRenderSurface = mOpenGLES->CreateSurface(swapChainPanel, nullptr, &customResolutionScale);
//
}
}
void OpenGLESPage::DestroyRenderSurface()
{
if (mOpenGLES)
{
mOpenGLES->DestroySurface(mRenderSurface);
}
mRenderSurface = EGL_NO_SURFACE;
}
void OpenGLESPage::RecoverFromLostDevice()
{
critical_section::scoped_lock lock(mRenderSurfaceCriticalSection);
DestroyRenderSurface();
mOpenGLES->Reset();
CreateRenderSurface();
std::unique_lock<std::mutex> locker(mSleepMutex);
mDeviceLost = false;
mSleepCondition.notify_one();
}
void OpenGLESPage::TerminateApp()
{
{
critical_section::scoped_lock lock(mRenderSurfaceCriticalSection);
if (mOpenGLES)
{
mOpenGLES->DestroySurface(mRenderSurface);
mOpenGLES->Cleanup();
}
}
Windows::UI::Xaml::Application::Current->Exit();
}
void OpenGLESPage::StartRenderLoop()
{
// If the render loop is already running then do not start another thread.
if (mRenderLoopWorker != nullptr && mRenderLoopWorker->Status == Windows::Foundation::AsyncStatus::Started)
{
return;
}
DisplayInformation^ currentDisplayInformation = DisplayInformation::GetForCurrentView();
mDpi = currentDisplayInformation->LogicalDpi;
auto dispatcher = Windows::UI::Xaml::Window::Current->CoreWindow->Dispatcher;
// Create a task for rendering that will be run on a background thread.
auto workItemHandler = ref new Windows::System::Threading::WorkItemHandler([this, dispatcher](Windows::Foundation::IAsyncAction ^ action)
{
mOpenGLES->MakeCurrent(mRenderSurface);
GLsizei panelWidth = 0;
GLsizei panelHeight = 0;
mOpenGLES->GetSurfaceDimensions(mRenderSurface, &panelWidth, &panelHeight);
if (mRenderer.get() == nullptr)
{
mRenderer = std::make_shared<Cocos2dRenderer>(panelWidth, panelHeight, mDpi, mOrientation, dispatcher, swapChainPanel);
}
mRenderer->Resume();
while (action->Status == Windows::Foundation::AsyncStatus::Started)
{
if (!mVisible)
{
mRenderer->Pause();
}
// wait until app is visible again or thread is cancelled
while (!mVisible)
{
std::unique_lock<std::mutex> lock(mSleepMutex);
mSleepCondition.wait(lock);
if (action->Status != Windows::Foundation::AsyncStatus::Started)
{
return; // thread was cancelled. Exit thread
}
if (mVisible)
{
mRenderer->Resume();
}
else // spurious wake up
{
continue;
}
}
mOpenGLES->GetSurfaceDimensions(mRenderSurface, &panelWidth, &panelHeight);
mRenderer.get()->Draw(panelWidth, panelHeight, mDpi, mOrientation);
// Recreate input dispatch
if (GLViewImpl::sharedOpenGLView() && mCursorVisible != GLViewImpl::sharedOpenGLView()->isCursorVisible())
{
CreateInput();
mCursorVisible = GLViewImpl::sharedOpenGLView()->isCursorVisible();
}
if (mRenderer->AppShouldExit())
{
// run on main UI thread
swapChainPanel->Dispatcher->RunAsync(Windows::UI::Core::CoreDispatcherPriority::High, ref new DispatchedHandler([=]()
{
TerminateApp();
}));
return;
}
EGLBoolean result = GL_FALSE;
{
critical_section::scoped_lock lock(mRenderSurfaceCriticalSection);
result = mOpenGLES->SwapBuffers(mRenderSurface);
}
if (result != GL_TRUE)
{
// The call to eglSwapBuffers was not be successful (i.e. due to Device Lost)
// If the call fails, then we must reinitialize EGL and the GL resources.
mRenderer->Pause();
mDeviceLost = true;
// XAML objects like the SwapChainPanel must only be manipulated on the UI thread.
swapChainPanel->Dispatcher->RunAsync(Windows::UI::Core::CoreDispatcherPriority::High, ref new Windows::UI::Core::DispatchedHandler([=]()
{
RecoverFromLostDevice();
}, CallbackContext::Any));
// wait until OpenGL is reset or thread is cancelled
while (mDeviceLost)
{
std::unique_lock<std::mutex> lock(mSleepMutex);
mSleepCondition.wait(lock);
if (action->Status != Windows::Foundation::AsyncStatus::Started)
{
return; // thread was cancelled. Exit thread
}
if (!mDeviceLost)
{
mOpenGLES->MakeCurrent(mRenderSurface);
// restart cocos2d-x
mRenderer->DeviceLost();
}
else // spurious wake up
{
continue;
}
}
}
}
});
// Run task on a dedicated high priority background thread.
mRenderLoopWorker = Windows::System::Threading::ThreadPool::RunAsync(workItemHandler, Windows::System::Threading::WorkItemPriority::High, Windows::System::Threading::WorkItemOptions::TimeSliced);
}
void OpenGLESPage::StopRenderLoop()
{
if (mRenderLoopWorker)
{
mRenderLoopWorker->Cancel();
std::unique_lock<std::mutex> locker(mSleepMutex);
mSleepCondition.notify_one();
mRenderLoopWorker = nullptr;
}
}
void OpenGLESPage::OnPointerPressed(Object^ sender, PointerEventArgs^ e)
{
bool isMouseEvent = e->CurrentPoint->PointerDevice->PointerDeviceType == Windows::Devices::Input::PointerDeviceType::Mouse;
if (mRenderer)
{
mRenderer->QueuePointerEvent(isMouseEvent ? PointerEventType::MousePressed : PointerEventType::PointerPressed, e);
}
}
void OpenGLESPage::OnPointerMoved(Object^ sender, PointerEventArgs^ e)
{
bool isMouseEvent = e->CurrentPoint->PointerDevice->PointerDeviceType == Windows::Devices::Input::PointerDeviceType::Mouse;
if (mRenderer)
{
mRenderer->QueuePointerEvent(isMouseEvent ? PointerEventType::MouseMoved : PointerEventType::PointerMoved, e);
}
}
void OpenGLESPage::OnPointerReleased(Object^ sender, PointerEventArgs^ e)
{
bool isMouseEvent = e->CurrentPoint->PointerDevice->PointerDeviceType == Windows::Devices::Input::PointerDeviceType::Mouse;
if (mRenderer)
{
mRenderer->QueuePointerEvent(isMouseEvent ? PointerEventType::MouseReleased : PointerEventType::PointerReleased, e);
}
}
void OpenGLESPage::OnPointerWheelChanged(Object^ sender, PointerEventArgs^ e)
{
bool isMouseEvent = e->CurrentPoint->PointerDevice->PointerDeviceType == Windows::Devices::Input::PointerDeviceType::Mouse;
if (mRenderer && isMouseEvent)
{
mRenderer->QueuePointerEvent(PointerEventType::MouseWheelChanged, e);
}
}
void OpenGLESPage::OnKeyPressed(CoreWindow^ sender, KeyEventArgs^ e)
{
//log("OpenGLESPage::OnKeyPressed %d", e->VirtualKey);
if (mRenderer)
{
mRenderer->QueueKeyboardEvent(WinRTKeyboardEventType::KeyPressed, e);
}
}
void OpenGLESPage::OnCharacterReceived(CoreWindow^ sender, CharacterReceivedEventArgs^ e)
{
#if 0
if (!e->KeyStatus.WasKeyDown)
{
log("OpenGLESPage::OnCharacterReceived %d", e->KeyCode);
}
#endif
}
void OpenGLESPage::OnKeyReleased(CoreWindow^ sender, KeyEventArgs^ e)
{
//log("OpenGLESPage::OnKeyReleased %d", e->VirtualKey);
if (mRenderer)
{
mRenderer->QueueKeyboardEvent(WinRTKeyboardEventType::KeyReleased, e);
}
}
void OpenGLESPage::OnOrientationChanged(DisplayInformation^ sender, Object^ args)
{
mOrientation = sender->CurrentOrientation;
}
void OpenGLESPage::SetVisibility(bool isVisible)
{
if (isVisible && mRenderSurface != EGL_NO_SURFACE)
{
if (!mVisible)
{
std::unique_lock<std::mutex> locker(mSleepMutex);
mVisible = true;
mSleepCondition.notify_one();
}
}
else
{
mVisible = false;
}
}
void OpenGLESPage::OnVisibilityChanged(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::VisibilityChangedEventArgs^ args)
{
if (args->Visible && mRenderSurface != EGL_NO_SURFACE)
{
SetVisibility(true);
}
else
{
SetVisibility(false);
}
}
#if (WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP) || _MSC_VER >= 1900
/*
We set args->Handled = true to prevent the app from quitting when the back button is pressed.
This is because this back button event happens on the XAML UI thread and not the cocos2d-x UI thread.
We need to give the game developer a chance to decide to exit the app depending on where they
are in their game. They can receive the back button event by listening for the
EventKeyboard::KeyCode::KEY_ESCAPE event.
The default behavior is to exit the app if the EventKeyboard::KeyCode::KEY_ESCAPE event
is not handled by the game.
*/
void OpenGLESPage::OnBackButtonPressed(Object^ sender, BackPressedEventArgs^ args)
{
if (mRenderer)
{
mRenderer->QueueBackButtonEvent();
args->Handled = true;
}
}
#endif | ecmas/cocos2d | cocos/platform/win8.1-universal/OpenGLESPage.xaml.cpp | C++ | mit | 16,993 | [
30522,
1013,
1008,
1008,
25033,
2015,
2475,
2094,
1011,
1060,
8299,
1024,
1013,
1013,
7479,
1012,
25033,
2015,
2475,
2094,
1011,
1060,
1012,
8917,
1008,
1008,
9385,
1006,
1039,
1007,
2230,
1011,
2297,
1011,
25033,
2015,
2475,
2094,
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... |
import Image from 'next/image'
import styles from '../styles/Home.module.scss'
import About from '../components/About/About'
import Header from '../components/Header/Header'
import Photo from '../components/Photo/Photo'
import { HomeContextProvider } from '../contexts/HomeContext/HomeContext'
import Events from '../components/Events/Events'
import Social from '../components/Social/Social'
import casualImg from '../public/casual.jpeg'
import scrumImg from '../public/scrum.jpeg'
import presentationImg from '../public/presentation.jpg'
import anniversaryImg from '../public/anniversary_cake.jpg'
import bgImg from '../public/bg.jpg'
export default function Home() {
return (
<HomeContextProvider>
<div className={styles.container}>
<div className={styles.bg}>
<Image
src={bgImg}
placeholder="blur"
layout="fill"
objectFit="cover"
objectPosition="center"
/>
</div>
<div className={styles.scrim} />
<Header />
<div className={styles.items}>
<About />
<Photo src={casualImg} />
<Photo src={scrumImg} />
<Photo src={presentationImg} />
<Events />
<Photo src={anniversaryImg} />
</div>
<Social />
</div>
</HomeContextProvider>
)
}
| qccoders/qccoders.org | pages/index.js | JavaScript | mit | 1,350 | [
30522,
12324,
3746,
2013,
1005,
2279,
1013,
3746,
1005,
12324,
6782,
2013,
1005,
1012,
1012,
1013,
6782,
1013,
2188,
1012,
11336,
1012,
8040,
4757,
1005,
12324,
2055,
2013,
1005,
1012,
1012,
1013,
6177,
1013,
2055,
1013,
2055,
1005,
12324,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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.Linq;
namespace CapnProto.Schema.Parser
{
class CapnpVisitor
{
protected Boolean mEnableNestedType = true;
protected CapnpModule mActiveModule;
protected void EnableNestedType()
{
mEnableNestedType = true;
}
protected void DisableNestedType()
{
mEnableNestedType = false;
}
public virtual CapnpType Visit(CapnpType target)
{
if (target == null) return null;
return target.Accept(this);
}
protected internal virtual CapnpType VisitPrimitive(CapnpPrimitive primitive)
{
return primitive;
}
protected internal virtual CapnpType VisitList(CapnpList list)
{
list.Parameter = Visit(list.Parameter);
return list;
}
protected internal virtual Value VisitValue(Value value)
{
return value;
}
protected internal virtual CapnpModule VisitModule(CapnpModule module)
{
// An imported module has already been processed.
if (mActiveModule != null && mActiveModule != module) return module;
mActiveModule = module;
module.Structs = module.Structs.Select(s => VisitStruct(s)).ToArray();
module.Interfaces = module.Interfaces.Select(i => VisitInterface(i)).ToArray();
module.Constants = module.Constants.Select(c => VisitConst(c)).ToArray();
module.Enumerations = module.Enumerations.Select(e => VisitEnum(e)).ToArray();
module.AnnotationDefs = module.AnnotationDefs.Select(a => VisitAnnotationDecl(a)).ToArray();
module.Usings = module.Usings.Select(u => VisitUsing(u)).ToArray();
module.Annotations = module.Annotations.Select(a => VisitAnnotation(a)).ToArray();
return module;
}
protected internal virtual Annotation VisitAnnotation(Annotation annotation)
{
if (annotation == null) return null;
annotation.Declaration = Visit(annotation.Declaration);
annotation.Argument = VisitValue(annotation.Argument);
return annotation;
}
protected internal virtual CapnpStruct VisitStruct(CapnpStruct @struct)
{
if (!mEnableNestedType) return @struct;
@struct.Structs = @struct.Structs.Select(s => VisitStruct(s)).ToArray();
@struct.Interfaces = @struct.Interfaces.Select(i => VisitInterface(i)).ToArray();
DisableNestedType();
@struct.Enumerations = @struct.Enumerations.Select(e => VisitEnum(e)).ToArray();
@struct.Fields = @struct.Fields.Select(f => VisitField(f)).ToArray();
@struct.AnnotationDefs = @struct.AnnotationDefs.Select(ad => VisitAnnotationDecl(ad)).ToArray();
@struct.Annotations = @struct.Annotations.Select(a => VisitAnnotation(a)).ToArray();
@struct.Usings = @struct.Usings.Select(u => VisitUsing(u)).ToArray();
@struct.Constants = @struct.Constants.Select(c => VisitConst(c)).ToArray();
EnableNestedType();
return @struct;
}
protected internal virtual CapnpInterface VisitInterface(CapnpInterface @interface)
{
if (!mEnableNestedType) return @interface;
@interface.Structs = @interface.Structs.Select(s => VisitStruct(s)).ToArray();
@interface.Interfaces = @interface.Interfaces.Select(i => VisitInterface(i)).ToArray();
DisableNestedType();
@interface.Enumerations = @interface.Enumerations.Select(e => VisitEnum(e)).ToArray();
@interface.BaseInterfaces = @interface.BaseInterfaces.Select(i => Visit(i)).ToArray();
@interface.AnnotationDefs = @interface.AnnotationDefs.Select(ad => VisitAnnotationDecl(ad)).ToArray();
@interface.Annotations = @interface.Annotations.Select(a => VisitAnnotation(a)).ToArray();
@interface.Methods = @interface.Methods.Select(m => VisitMethod(m)).ToArray();
@interface.Usings = @interface.Usings.Select(u => VisitUsing(u)).ToArray();
@interface.Constants = @interface.Constants.Select(c => VisitConst(c)).ToArray();
EnableNestedType();
return @interface;
}
protected internal virtual CapnpGenericParameter VisitGenericParameter(CapnpGenericParameter @param)
{
return @param;
}
protected internal virtual CapnpBoundGenericType VisitClosedType(CapnpBoundGenericType closed)
{
closed.OpenType = (CapnpNamedType)Visit(closed.OpenType);
if (closed.ParentScope != null)
closed.ParentScope = VisitClosedType(closed.ParentScope);
return closed;
}
protected internal virtual CapnpEnum VisitEnum(CapnpEnum @enum)
{
@enum.Annotations = @enum.Annotations.Select(a => VisitAnnotation(a)).ToArray();
@enum.Enumerants = @enum.Enumerants.Select(e => VisitEnumerant(e)).ToArray();
return @enum;
}
protected internal virtual Enumerant VisitEnumerant(Enumerant e)
{
e.Annotation = VisitAnnotation(e.Annotation);
return e;
}
protected internal virtual Field VisitField(Field fld)
{
fld.Type = Visit(fld.Type);
fld.Value = VisitValue(fld.Value);
fld.Annotation = VisitAnnotation(fld.Annotation);
return fld;
}
protected internal virtual Method VisitMethod(Method method)
{
if (method.Arguments.Params != null)
method.Arguments.Params = method.Arguments.Params.Select(p => VisitParameter(p)).ToArray();
else
method.Arguments.Struct = Visit(method.Arguments.Struct);
if (method.ReturnType.Params != null)
method.ReturnType.Params = method.ReturnType.Params.Select(p => VisitParameter(p)).ToArray();
else
method.ReturnType.Struct = Visit(method.ReturnType.Struct);
method.Annotation = VisitAnnotation(method.Annotation);
return method;
}
protected internal virtual Parameter VisitParameter(Parameter p)
{
p.Type = Visit(p.Type);
p.Annotation = VisitAnnotation(p.Annotation);
p.DefaultValue = VisitValue(p.DefaultValue);
return p;
}
protected internal virtual CapnpGroup VisitGroup(CapnpGroup grp)
{
grp.Fields = grp.Fields.Select(f => VisitField(f)).ToArray();
return grp;
}
protected internal virtual CapnpUnion VisitUnion(CapnpUnion union)
{
union.Fields = union.Fields.Select(u => VisitField(u)).ToArray();
return union;
}
protected internal virtual CapnpType VisitReference(CapnpReference @ref)
{
return @ref;
}
protected internal virtual CapnpConst VisitConst(CapnpConst @const)
{
@const.Value = VisitValue(@const.Value);
return @const;
}
protected internal virtual CapnpType VisitImport(CapnpImport import)
{
import.Type = Visit(import.Type);
return import;
}
protected internal virtual CapnpUsing VisitUsing(CapnpUsing @using)
{
@using.Target = Visit(@using.Target);
return @using;
}
protected internal virtual CapnpAnnotation VisitAnnotationDecl(CapnpAnnotation annotation)
{
annotation.ArgumentType = Visit(annotation.ArgumentType);
return annotation;
}
}
} | tempbottle/capnproto-net | CapnProto.net.Schema/Parser/CapnpVisitor.cs | C# | mit | 7,402 | [
30522,
2478,
2291,
1025,
2478,
2291,
1012,
11409,
4160,
1025,
3415,
15327,
6178,
16275,
21709,
2080,
1012,
8040,
28433,
1012,
11968,
8043,
1063,
2465,
6178,
16275,
11365,
15660,
1063,
5123,
22017,
20898,
2273,
3085,
5267,
3064,
13874,
1027,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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 class="no-js" lang="ko">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="p5.js a JS client-side library for creating graphic and interactive experiences, based on the core principles of Processing.">
<title tabindex="1">examples | p5.js</title>
<link rel="stylesheet" href="/assets/css/all.css?v=4c8161">
<link href="https://fonts.googleapis.com/css?family=Montserrat&display=swap" rel="stylesheet">
<link href="https://fonts.googleapis.com/css2?family=Inconsolata&display=swap" rel="stylesheet">
<link rel="shortcut icon" href="/../../assets/img/favicon.ico">
<link rel="icon" href="/../../assets/img/favicon.ico">
<script src="/../../assets/js/vendor/jquery-1.12.4.min.js"></script>
<script src="/../../assets/js/vendor/ace-nc/ace.js"></script>
<script src="/../../assets/js/vendor/ace-nc/mode-javascript.js"></script>
<script src="/../../assets/js/vendor/prism.js"></script>
<script src="/assets/js/init.js?v=97b4f7"></script>
</head>
<body>
<a href="#content" class="sr-only">건너뛰기</a>
<!-- p5*js language buttons -->
<div id="i18n-btn">
<h2 id="i18n-settings" class="sr-only">언어 설정</h2>
<ul id="i18n-buttons" aria-labelledby="i18n-settings">
<li><a href='#' lang='en' data-lang='en'>English</a></li>
<li><a href='#' lang='es' data-lang='es'>Español</a></li>
<li><a href='#' lang='zh-Hans' data-lang='zh-Hans'>简体中文</a></li>
<li><a href='#' lang='ko' data-lang='ko'>한국어</a></li>
<li><a href='#' lang='hi' data-lang='hi'>हिन्दी</a></li>
</ul>
</div> <!-- .container -->
<div class="container">
<!-- logo -->
<header id="lockup">
<a href="/ko/">
<img src="/../../assets/img/p5js.svg" alt="p5 homepage" id="logo_image" class="logo" />
<div id="p5_logo"></div>
</a>
</header>
<!-- close logo -->
<div id="examples-page">
<!-- site navigation -->
<div class="column-span">
<nav class="sidebar-menu-nav-element">
<h2 id="menu-title" class="sr-only">사이트 둘러보기</h2>
<input class="sidebar-menu-btn" type="checkbox" id="sidebar-menu-btn" />
<label class="sidebar-menu-icon" for="sidebar-menu-btn"><span class="sidebar-nav-icon"></span></label>
<ul id="menu" class="sidebar-menu" aria-labelledby="menu-title">
<li><a href="/ko/">홈</a></li>
<li><a href="https://editor.p5js.org">에디터</a></li>
<li><a href="/ko/download/">다운로드</a></li>
<li><a href="/ko/download/support.html">후원하기</a></li>
<li><a href="/ko/get-started/">시작하기</a></li>
<li><a href="/ko/reference/">레퍼런스</a></li>
<li><a href="/ko/libraries/">라이브러리</a></li>
<li><a href="/ko/learn/">배우기</a></li>
<li><a href="/ko/teach/">가르치기</a></li>
<li><a href="/ko/examples/">예제</a></li>
<li><a href="/ko/books/">출판물</a></li>
<li><a href="/ko/community/">커뮤니티</a></li>
<li><a href="https://showcase.p5js.org">쇼케이스</a></li>
<li><a href="https://discourse.processing.org/c/p5js" target=_blank class="other-link">포럼</a></li>
<li><a href="http://github.com/processing/p5.js" target=_blank class="other-link">GitHub</a></li>
<li><a href="http://twitter.com/p5xjs" target=_blank class="other-link">Twitter</a></li>
<li><a href="https://www.instagram.com/p5xjs/" target=_blank class="other-link">Instagram</a></li>
<li><a href="https://discord.gg/SHQ8dH25r9" target=_blank class="other-link">Discord</a></li>
</ul>
</nav>
</div>
<div class="column-span">
<main id="content" >
<p id="backlink"><a href="./">< 돌아가기</a></p>
<h1 id='example-name'>example name placeholder</h1>
<p id='example-desc'>example description placeholder</p>
<div id="exampleDisplay">
<div class="edit_space">
<button id="toggleTextOutput" class="sr-only">toggle text output</button>
<button id="runButton" class="edit_button">run</button>
<button id="resetButton" class="reset_button">reset</button>
<button id="copyButton" class="copy_button">copy</button>
</div>
<div id="exampleEditor"></div>
<iframe id="exampleFrame" src="../../assets/examples/example.html" aria-label="example arialabel placeholder" ></iframe>
</div>
<p><a style="border-bottom:none !important;" href="https://creativecommons.org/licenses/by-nc-sa/4.0/" target=_blank><img src="https://licensebuttons.net/l/by-nc-sa/4.0/88x31.png" alt="creative commons license" style="width:88px"/></a></p>
</main>
<footer>
<h2 class="sr-only">크레딧</h2>
<p>
p5.js는 현재 치안치안 예<a href='http://qianqian-ye.com/' target="_blank">Qianqian Ye</a> & 에블린 마소<a href='http://www.outofambit.com/' target="_blank">evelyn masso</a> 가 리드하고, 로렌 맥카시 <a href='https://lauren-mccarthy.com' target="_blank">Lauren Lee McCarthy</a> 가 창안하였습니다. p5.js는 프로세싱 재단 <a href="https://processingfoundation.org/" target="_blank">Processing Foundation</a> 과 <a href="https://itp.nyu.edu/itp/" target="_blank">NYU ITP</a> 의 지원으로, 협력자 커뮤니티와 함께 개발되었습니다. 아이덴티티 및 그래픽 디자인: 제럴 존슨 <a href="https://jereljohnson.com/" target="_blank">Jerel Johnson</a>. <a href="/ko/copyright.html">© Info</a>.
</p>
</footer>
</div> <!-- end column-span -->
<!-- outside of column for footer to go across both -->
<p class="clearfix"> </p>
<object type="image/svg+xml" data="../../assets/img/thick-asterisk-alone.svg" id="asterisk-design-element" aria-hidden="true">
</object>
<!-- <script src="../../assets/js/vendor/ace-nc/ace.js"></script>
<script src="../../assets/js/examples.js"></script> -->
<script>
window._p5jsExample = '../../assets/examples/ko/33_Sound/05_Sound_Effect.js';
window.addEventListener('load', function() {
// examples.init('../../assets/examples/ko/33_Sound/05_Sound_Effect.js');
if (false) {
var isMobile = window.matchMedia("only screen and (max-width: 767px)");
// isMobile is true if viewport is less than 768 pixels wide
document.getElementById('exampleFrame').style.display = 'none';
if (isMobile.matches) {
document.getElementById('notMobile-message').style.display = 'none';
document.getElementById('isMobile-displayButton').style.display = 'block';
} else {
document.getElementById('notMobile-message').style.display = 'block';
document.getElementById('isMobile-displayButton').style.display = 'none';
document.getElementById('runButton').style.display = 'none';
document.getElementById('resetButton').style.display = 'none';
document.getElementById('copyButton').style.display = 'none';
}
}
}, true);
</script>
</div><!-- end id="get-started-page" -->
<script src="/../../assets/js/examples.js"></script>
</div> <!-- close class='container'-->
<nav id="family" aria-labelledby="processing-sites-heading">
<h2 id="processing-sites-heading" class="sr-only">Processing Sister Sites</h2>
<ul id="processing-sites" aria-labelledby="processing-sites-heading">
<li><a href="https://processing.org">Processing</a></li>
<li><a class="here" href="/ko/">p5.js</a></li>
<li><a href="https://py.processing.org/">Processing.py</a></li>
<li><a href="https://android.processing.org/">Processing for Android</a></li>
<li><a href="https://pi.processing.org/">Processing for Pi</a></li>
<li><a href="https://processingfoundation.org/">Processing Foundation</a></li>
</ul>
<a tabindex="1" href="#content" id="skip-to-content">Skip to main content</a>
</nav>
<script>
var langs = ["en","es","hi","ko","zh-Hans"];
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-53383000-1', 'auto');
ga('send', 'pageview');
$(window).ready(function() {
if (window.location.pathname !== '/' && window.location.pathname !== '/index.html') {
$('#top').remove();
} else {
$('#top').show();
}
});
</script>
</body>
</html>
| mayaman26/p5js-website | ko/examples/sound-sound-effect.html | HTML | mit | 8,967 | [
30522,
1026,
999,
9986,
13874,
16129,
1028,
1026,
30524,
18804,
25869,
13462,
1027,
1000,
21183,
2546,
1011,
1022,
1000,
1028,
1026,
18804,
8299,
1011,
1041,
15549,
2615,
1027,
1000,
1060,
1011,
25423,
1011,
11892,
1000,
4180,
1027,
1000,
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... |
#totalsbox {
text-align:center;
}
#totalsbox span.mid p {
margin-left:0;
margin-right:0;
}
* {
font-family:Arial, 'Helvetica Neue', Helvetica, sans-serif;
}
.c3-axis line,.c3-grid,.domain {
display:none;
}
.c3-tooltip-container th {
background-color:#104060;
}
.chartHeader {
color:#FFF;
text-align:right;
}
.chartHeader p {
background-color:#ddd;
color:#000;
font-style:italic;
margin:0;
padding:5px;
text-align:right;
}
.container {
display:inline-block;
margin:1% 10%;
max-width:80%;
min-width:380px;
width:75%;
}
.data {
max-width:300px;
width:30%;
}
.data p {
border:none;
margin:5px;
}
.form {
background-color:#f2f6f8;
border-color:#0f0f0f;
border-style:solid;
border-width:3px;
display:table;
margin:0 auto;
padding:0 15px;
text-align:left;
width:400px;
}
.headertext {
float:right;
height:59px;
overflow:hidden;
padding:13px 10px;
text-align:center;
}
.instructions {
color:#b5bec6;
font-size:10px;
text-align:center;
}
.instructions b {
color:#FFF;
font-size:12px;
}
.instructions p {
font-size:10px;
margin:0 35%;
max-width:500px;
padding:5px;
}
.left {
display:inline-block;
max-width:55%;
min-width:55%;
padding-right:2%;
text-align:right;
}
.loadingbar {
background-color:#b5bec6;
color:#49111c;
text-align:center;
}
.logoHeader {
display:block;
height:59px;
overflow:hidden;
width:100%;
}
.maininstrux {
margin:2% 0 0;
}
.right {
color:#FFF;
display:inline-block;
font-weight:700;
max-width:43%;
min-width:43%;
text-align:left;
}
.sm {
font-size:8px;
}
.splitblock {
display:inline-block;
margin:0 0 2px;
padding:0;
text-align:center;
}
.splitblock p {
color:#ddd;
margin:3px;
}
.submit {
background-color:#00b300;
border-radius:3px;
color:#FFF;
cursor:pointer;
font-weight:700;
margin:0 auto 10px;
max-width:350px;
padding:5px;
text-align:center;
}
.themelink span {
cursor:pointer;
padding-left:.5%;
padding-right:.5%;
}
.tick text {
fill:#FFF;
}
a {
color:#5c0029;
font-weight:700;
text-decoration:none;
}
body {
background-color:#333340;
margin:0;
min-width:500px;
padding:0;
}
h1 {
color:#FFF;
display:inline;
font-family:Arial, 'Helvetica Neue', Helvetica, sans-serif;
font-size:24px;
font-style:normal;
font-variant:normal;
font-weight:500;
text-align:right;
}
h3 {
font-family:Arial, 'Helvetica Neue', Helvetica, sans-serif;
font-size:14px;
font-style:normal;
font-variant:normal;
font-weight:500;
line-height:15.4px;
margin:0;
padding:5px;
}
| VerstandInvictus/PatternsEmerge | webapp/css/main.css | CSS | mit | 2,827 | [
30522,
1001,
21948,
8758,
1063,
3793,
1011,
25705,
1024,
2415,
1025,
1065,
1001,
21948,
8758,
8487,
1012,
3054,
1052,
1063,
7785,
1011,
2187,
1024,
1014,
1025,
7785,
1011,
2157,
1024,
1014,
1025,
1065,
1008,
1063,
15489,
1011,
2155,
1024,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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... |
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link rel="stylesheet" href="./../../helpwin.css">
<title>MATLAB File Help: prtKernelRbfNdimensionScale/dataSetSummary</title>
</head>
<body>
<!--Single-page help-->
<table border="0" cellspacing="0" width="100%">
<tr class="subheader">
<td class="headertitle">MATLAB File Help: prtKernelRbfNdimensionScale/dataSetSummary</td>
</tr>
</table>
<div class="title">prtKernelRbfNdimensionScale/dataSetSummary</div>
<div class="helptext"><pre><!--helptext --> Structure that summarizes prtDataSet.
Help for <span class="helptopic">prtKernelRbfNdimensionScale/dataSetSummary</span> is inherited from superclass <a href="./../prtAction.html">prtAction</a></pre></div><!--after help -->
<!--Property-->
<div class="sectiontitle">Property Details</div>
<table class="class-details">
<tr>
<td class="class-detail-label">Constant</td>
<td>false</td>
</tr>
<tr>
<td class="class-detail-label">Dependent</td>
<td>false</td>
</tr>
<tr>
<td class="class-detail-label">Sealed</td>
<td>false</td>
</tr>
<tr>
<td class="class-detail-label">Transient</td>
<td>false</td>
</tr>
<tr>
<td class="class-detail-label">GetAccess</td>
<td>public</td>
</tr>
<tr>
<td class="class-detail-label">SetAccess</td>
<td>protected</td>
</tr>
<tr>
<td class="class-detail-label">GetObservable</td>
<td>false</td>
</tr>
<tr>
<td class="class-detail-label">SetObservable</td>
<td>false</td>
</tr>
</table>
</body>
</html> | covartech/PRT | doc/functionReference/prtKernelRbfNdimensionScale/dataSetSummary.html | HTML | mit | 1,946 | [
30522,
1026,
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,
1026,
4957,
2128... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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 thrift
import (
"context"
"errors"
"fmt"
)
const (
VERSION_MASK = 0xffff0000
VERSION_1 = 0x80010000
)
type TProtocol interface {
WriteMessageBegin(ctx context.Context, name string, typeId TMessageType, seqid int32) error
WriteMessageEnd(ctx context.Context) error
WriteStructBegin(ctx context.Context, name string) error
WriteStructEnd(ctx context.Context) error
WriteFieldBegin(ctx context.Context, name string, typeId TType, id int16) error
WriteFieldEnd(ctx context.Context) error
WriteFieldStop(ctx context.Context) error
WriteMapBegin(ctx context.Context, keyType TType, valueType TType, size int) error
WriteMapEnd(ctx context.Context) error
WriteListBegin(ctx context.Context, elemType TType, size int) error
WriteListEnd(ctx context.Context) error
WriteSetBegin(ctx context.Context, elemType TType, size int) error
WriteSetEnd(ctx context.Context) error
WriteBool(ctx context.Context, value bool) error
WriteByte(ctx context.Context, value int8) error
WriteI16(ctx context.Context, value int16) error
WriteI32(ctx context.Context, value int32) error
WriteI64(ctx context.Context, value int64) error
WriteDouble(ctx context.Context, value float64) error
WriteString(ctx context.Context, value string) error
WriteBinary(ctx context.Context, value []byte) error
ReadMessageBegin(ctx context.Context) (name string, typeId TMessageType, seqid int32, err error)
ReadMessageEnd(ctx context.Context) error
ReadStructBegin(ctx context.Context) (name string, err error)
ReadStructEnd(ctx context.Context) error
ReadFieldBegin(ctx context.Context) (name string, typeId TType, id int16, err error)
ReadFieldEnd(ctx context.Context) error
ReadMapBegin(ctx context.Context) (keyType TType, valueType TType, size int, err error)
ReadMapEnd(ctx context.Context) error
ReadListBegin(ctx context.Context) (elemType TType, size int, err error)
ReadListEnd(ctx context.Context) error
ReadSetBegin(ctx context.Context) (elemType TType, size int, err error)
ReadSetEnd(ctx context.Context) error
ReadBool(ctx context.Context) (value bool, err error)
ReadByte(ctx context.Context) (value int8, err error)
ReadI16(ctx context.Context) (value int16, err error)
ReadI32(ctx context.Context) (value int32, err error)
ReadI64(ctx context.Context) (value int64, err error)
ReadDouble(ctx context.Context) (value float64, err error)
ReadString(ctx context.Context) (value string, err error)
ReadBinary(ctx context.Context) (value []byte, err error)
Skip(ctx context.Context, fieldType TType) (err error)
Flush(ctx context.Context) (err error)
Transport() TTransport
}
// The maximum recursive depth the skip() function will traverse
const DEFAULT_RECURSION_DEPTH = 64
// Skips over the next data element from the provided input TProtocol object.
func SkipDefaultDepth(ctx context.Context, prot TProtocol, typeId TType) (err error) {
return Skip(ctx, prot, typeId, DEFAULT_RECURSION_DEPTH)
}
// Skips over the next data element from the provided input TProtocol object.
func Skip(ctx context.Context, self TProtocol, fieldType TType, maxDepth int) (err error) {
if maxDepth <= 0 {
return NewTProtocolExceptionWithType(DEPTH_LIMIT, errors.New("Depth limit exceeded"))
}
switch fieldType {
case BOOL:
_, err = self.ReadBool(ctx)
return
case BYTE:
_, err = self.ReadByte(ctx)
return
case I16:
_, err = self.ReadI16(ctx)
return
case I32:
_, err = self.ReadI32(ctx)
return
case I64:
_, err = self.ReadI64(ctx)
return
case DOUBLE:
_, err = self.ReadDouble(ctx)
return
case STRING:
_, err = self.ReadString(ctx)
return
case STRUCT:
if _, err = self.ReadStructBegin(ctx); err != nil {
return err
}
for {
_, typeId, _, err := self.ReadFieldBegin(ctx)
if err != nil {
return err
}
if typeId == STOP {
break
}
err = Skip(ctx, self, typeId, maxDepth-1)
if err != nil {
return err
}
self.ReadFieldEnd(ctx)
}
return self.ReadStructEnd(ctx)
case MAP:
keyType, valueType, size, err := self.ReadMapBegin(ctx)
if err != nil {
return err
}
for i := 0; i < size; i++ {
err := Skip(ctx, self, keyType, maxDepth-1)
if err != nil {
return err
}
err = Skip(ctx, self, valueType, maxDepth-1)
if err != nil {
return err
}
}
return self.ReadMapEnd(ctx)
case SET:
elemType, size, err := self.ReadSetBegin(ctx)
if err != nil {
return err
}
for i := 0; i < size; i++ {
err := Skip(ctx, self, elemType, maxDepth-1)
if err != nil {
return err
}
}
return self.ReadSetEnd(ctx)
case LIST:
elemType, size, err := self.ReadListBegin(ctx)
if err != nil {
return err
}
for i := 0; i < size; i++ {
err := Skip(ctx, self, elemType, maxDepth-1)
if err != nil {
return err
}
}
return self.ReadListEnd(ctx)
default:
return NewTProtocolExceptionWithType(INVALID_DATA, fmt.Errorf("Unknown data type %d", fieldType))
}
return nil
}
| admpub/nging | vendor/github.com/apache/thrift/lib/go/thrift/protocol.go | GO | agpl-3.0 | 5,738 | [
30522,
1013,
1008,
1008,
7000,
2000,
1996,
15895,
4007,
3192,
1006,
2004,
2546,
1007,
2104,
2028,
1008,
2030,
2062,
12130,
6105,
10540,
1012,
2156,
1996,
5060,
5371,
1008,
5500,
2007,
2023,
2147,
2005,
3176,
2592,
1008,
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... |
using System.ComponentModel;
using System.Web.Script.Serialization;
using MongoDB.Bson;
namespace TitanicCrawler.Albums
{
public abstract class Album
{
private string artist;
private string album;
/// <summary>
/// Creates a new Album class which takes all 6 arguments
/// </summary>
/// <param name="artist">The artist name of the album</param>
/// <param name="albumTitle">The title of the album</param>
protected Album(string artist, string albumTitle)
{
Artist = artist;
AlbumTitle = albumTitle;
}
public Album(BsonDocument albumDocuement)
{
Artist = albumDocuement["Artist"].ToString();
AlbumTitle = albumDocuement["Album"].ToString();
}
/// <summary>
/// The artist name of the album
/// </summary>
[DisplayName("Artist")]
public string Artist
{
get { return artist; }
set { artist = value; }
}
/// <summary>
/// The title of the album
/// </summary>
[DisplayName("Album Title")]
public string AlbumTitle
{
get { return album; }
set { album = value; }
}
/// <summary>
/// Returns a JSON string of the object
/// </summary>
/// <returns></returns>
public string toJSON()
{
return new JavaScriptSerializer().Serialize(this);
}
/// <summary>
/// Returns a BSON Representation of the Album Object
/// </summary>
/// <returns>BSON representation of Album</returns>
public abstract BsonDocument BsonDocument
{
get;
}
}
}
| Ramzy94/TitanicWebCrawler | TitanicCrawler/Albums/Album.cs | C# | gpl-3.0 | 1,792 | [
30522,
2478,
2291,
1012,
6922,
5302,
9247,
1025,
2478,
2291,
1012,
4773,
1012,
5896,
1012,
7642,
3989,
1025,
2478,
12256,
3995,
18939,
1012,
18667,
2239,
1025,
3415,
15327,
20753,
26775,
10376,
3917,
1012,
4042,
1063,
2270,
10061,
2465,
220... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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... |
const fs = require('fs');
module.exports = (params) => () => {
fs.writeFileSync(`${params.projectRoot}/License.md`, params.license);
return 'licenseMd: ok';
};
| tomekwi/boilerplate | templates/_/actions/licenseMd.js | JavaScript | mit | 166 | [
30522,
9530,
3367,
1042,
2015,
1027,
5478,
1006,
1005,
1042,
2015,
1005,
1007,
1025,
11336,
1012,
14338,
1027,
1006,
11498,
5244,
1007,
1027,
1028,
1006,
1007,
1027,
1028,
1063,
1042,
2015,
1012,
4339,
8873,
4244,
6038,
2278,
1006,
1036,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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) 2009, 2010 EPITA Research and Development Laboratory
// (LRDE)
//
// This file is part of Olena.
//
// Olena 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, version 2 of the License.
//
// Olena 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 Olena. If not, see <http://www.gnu.org/licenses/>.
//
// As a special exception, you may use this file as part of a free
// software project without restriction. Specifically, if other files
// instantiate templates or use macros or inline functions from this
// file, or you compile this file and link it with other files to produce
// an executable, this file does not by itself cause the resulting
// executable to be covered by the GNU General Public License. This
// exception does not however invalidate any other reasons why the
// executable file might be covered by the GNU General Public License.
#ifndef SCRIBO_BINARIZATION_GLOBAL_THRESHOLD_AUTO_HH
# define SCRIBO_BINARIZATION_GLOBAL_THRESHOLD_AUTO_HH
/// \file
///
/// Binarize a graylevel image using an automatic global threshold.
///
/// FIXME: Adapt the filtering if no threshold is found.
# include <mln/core/image/image1d.hh>
# include <mln/core/alias/neighb1d.hh>
# include <mln/core/image/image2d.hh>
# include <mln/core/alias/neighb2d.hh>
# include <mln/core/routine/duplicate.hh>
# include <mln/core/image/dmorph/image_if.hh>
# include <mln/pw/all.hh>
# include <mln/histo/compute.hh>
# include <mln/debug/histo.hh>
# include <mln/convert/from_to.hh>
# include <mln/morpho/elementary/gradient_external.hh>
# include <mln/morpho/closing/height.hh>
# include <mln/morpho/closing/volume.hh>
# include <mln/morpho/watershed/flooding.hh>
# include <mln/linear/gaussian_1d.hh>
# include <mln/labeling/regional_minima.hh>
# include <mln/labeling/compute.hh>
# include <mln/value/label_8.hh>
# include <mln/accu/center.hh>
namespace scribo
{
namespace binarization
{
using namespace mln;
/// \brief Simple binarization of a gray-level document.
/*!
Automatically find a global threshold for the given image.
\param[in] input A gray-level image.
\result A Boolean image.
*/
template <typename I>
mln_ch_value(I, bool)
global_threshold_auto(const Image<I>& input);
# ifndef MLN_INCLUDE_ONLY
template <typename I>
inline
mln_ch_value(I, bool)
global_threshold_auto(const Image<I>& input_)
{
mln_trace("scribo::binarization::global_threshold_auto");
const I& input = exact(input_);
mln_precondition(input.is_valid());
const float sigma = 5; // FIXME: hard-coded!
typedef mln_value(I) V;
histo::array<V> h;
{
mln_concrete(I) g;
g = morpho::elementary::gradient_external(input, c4());
g = morpho::closing::height(g, c4(), 5); // FIXME: hard-coded!
unsigned nbasins;
mln_ch_value(I, unsigned) w = morpho::watershed::flooding(g, c4(), nbasins);
h = histo::compute(input | (pw::value(w) == pw::cst(0u)));
}
util::array<point1d> c;
value::label_8 n;
{
image1d<unsigned> h_, hs_;
image1d<value::label_8> l;
convert::from_to(h, h_);
hs_ = linear::gaussian_1d(h_, sigma, 0);
l = labeling::regional_minima(hs_, c2(), n);
if (n < 3u)
{
std::cerr << "This method has not worked properly!" << std::endl;
debug::histo(h, "tmp_h.txt");
std::ofstream file("tmp_hs.txt");
mln_piter(box1d) p(h_.domain());
for_all(p)
file << p.ind() << ' ' << hs_(p) << std::endl;
file.close();
std::abort();
}
accu::center<point1d, point1d> a;
c = labeling::compute(a, l, n);
c[0] = point1d(0); // Force a neutral value for the non-label value (0).
}
unsigned threshold;
{
std::vector<int> v;
for (unsigned i = 0; i <= n; ++i)
v.push_back(c[i].ind());
std::sort(v.begin(), v.end());
threshold = v[n.prev()];
}
mln_ch_value(I, bool) output;
output = duplicate((pw::value(input) < pw::cst(threshold)) | input.domain());
return output;
}
# endif // !MLN_INCLUDE_ONLY
} // end of namespace scribo::binarization
} // end of namespace scribo
#endif // ! SCRIBO_BINARIZATION_GLOBAL_THRESHOLD_AUTO_HH
| glazzara/olena | scribo/scribo/binarization/global_threshold_auto.hh | C++ | gpl-2.0 | 4,566 | [
30522,
1013,
1013,
9385,
1006,
1039,
1007,
2268,
1010,
2230,
4958,
6590,
2470,
1998,
2458,
5911,
1013,
1013,
1006,
1048,
25547,
1007,
1013,
1013,
1013,
1013,
2023,
5371,
2003,
2112,
1997,
15589,
2532,
1012,
1013,
1013,
1013,
1013,
15589,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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 { t } from 'app/i18next-t';
import { DimCrafted } from 'app/inventory/item-types';
import { percent } from 'app/shell/filters';
import React from 'react';
/**
* A progress bar that shows weapon crafting info like the game does.
*/
export function WeaponCraftedInfo({
craftInfo,
className,
}: {
craftInfo: DimCrafted;
className: string;
}) {
const pct = percent(craftInfo.progress || 0);
const progressBarStyle = {
width: pct,
};
return (
<div className={className}>
<div className="objective-progress">
<div className="objective-progress-bar" style={progressBarStyle} />
<div className="objective-description">
{t('MovePopup.WeaponLevel', { level: craftInfo.level })}
</div>
<div className="objective-text">{pct}</div>
</div>
</div>
);
}
| DestinyItemManager/DIM | src/app/dim-ui/WeaponCraftedInfo.tsx | TypeScript | mit | 833 | [
30522,
12324,
1063,
1056,
1065,
2013,
1005,
10439,
1013,
1045,
15136,
2638,
18413,
1011,
1056,
1005,
1025,
12324,
1063,
11737,
10419,
2098,
1065,
2013,
1005,
10439,
1013,
12612,
1013,
8875,
1011,
4127,
1005,
1025,
12324,
1063,
3867,
1065,
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... |
package com.yaochen.boss.dao;
import java.util.List;
import org.springframework.stereotype.Component;
import com.ycsoft.beans.core.cust.CCust;
import com.ycsoft.beans.core.prod.CProdInclude;
import com.ycsoft.daos.abstracts.BaseEntityDao;
import com.ycsoft.daos.core.JDBCException;
@Component
public class ProdIncludeDao extends BaseEntityDao<CCust> {
public ProdIncludeDao(){}
//设置产品之间的关系
public void saveProdInclude(String userId,List<CProdInclude> includeList) throws Exception{
for (CProdInclude include :includeList){
String sql = "insert into c_prod_include_lxr (cust_id,user_id,prod_sn,include_prod_sn) " +
" values (?,?,?,?)";
executeUpdate(sql,include.getCust_id(),include.getUser_id(),include.getProd_sn(),include.getInclude_prod_sn());
}
}
}
| leopardoooo/cambodia | boss-job/src/main/java/com/yaochen/boss/dao/ProdIncludeDao.java | Java | apache-2.0 | 826 | [
30522,
7427,
4012,
1012,
23711,
8661,
1012,
5795,
1012,
4830,
2080,
1025,
12324,
9262,
1012,
21183,
4014,
1012,
2862,
1025,
12324,
8917,
1012,
3500,
15643,
6198,
1012,
12991,
13874,
1012,
6922,
1025,
12324,
4012,
1012,
1061,
6169,
15794,
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... |
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
namespace YouWalk.Portal.Controllers
{
public class IndexController : Controller
{
public ActionResult Index()
{
return View();
}
}
} | rakhmanoff/YouWalk | YouWalk/Controllers/IndexController.cs | C# | gpl-2.0 | 292 | [
30522,
2478,
2291,
1025,
2478,
2291,
1012,
6407,
1012,
12391,
1025,
2478,
2291,
1012,
11409,
4160,
1025,
2478,
2291,
1012,
4773,
1025,
2478,
2291,
1012,
4773,
1012,
19842,
2278,
1025,
3415,
15327,
2017,
17122,
1012,
9445,
1012,
21257,
1063,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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 React, { Component } from 'react'
import { connect } from 'react-redux'
import { setSearchTerm } from './actionCreators'
import { Link } from 'react-router'
class Header extends Component {
constructor (props) {
super(props)
this.handleSearchTermChange = this.handleSearchTermChange.bind(this)
}
handleSearchTermChange (event) {
this.props.dispatch(setSearchTerm(event.target.value))
}
render () {
let utilSpace
if (this.props.showSearch) {
utilSpace = <input onChange={this.handleSearchTermChange} value={this.props.searchTerm} type='text' placeholder='Search' />
} else {
utilSpace = (
<h2>
<Link to='/search'>Back</Link>
</h2>
)
}
return (
<header>
<h1>
<Link to='/'>
jordaflix
</Link>
</h1>
{utilSpace}
</header>
)
}
}
const mapStateToProps = (state) => {
return {
searchTerm: state.searchTerm
}
}
const { func, bool, string } = React.PropTypes
Header.propTypes = {
handleSearchTermChange: func,
dispatch: func,
showSearch: bool,
searchTerm: string
}
export default connect(mapStateToProps)(Header)
| joordas/react-fem | js/Header.js | JavaScript | mit | 1,191 | [
30522,
12324,
10509,
1010,
1063,
6922,
1065,
2013,
1005,
10509,
1005,
12324,
1063,
7532,
1065,
2013,
1005,
10509,
1011,
2417,
5602,
1005,
12324,
1063,
4520,
14644,
10143,
2121,
2213,
1065,
2013,
1005,
1012,
1013,
2895,
16748,
18926,
1005,
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... |
# Elasticsearch for Kubernetes
This directory contains the source for a Docker image that creates an instance
of [Elasticsearch](https://www.elastic.co/products/elasticsearch) 1.5.2 which can
be used to automatically form clusters when used
with [replication controllers](../../docs/replication-controller.md). This will not work with the library Elasticsearch image
because multicast discovery will not find the other pod IPs needed to form a cluster. This
image detects other Elasticsearch [pods](../../docs/pods.md) running in a specified [namespace](../../docs/namespaces.md) with a given
label selector. The detected instances are used to form a list of peer hosts which
are used as part of the unicast discovery mechansim for Elasticsearch. The detection
of the peer nodes is done by a program which communicates with the Kubernetes API
server to get a list of matching Elasticsearch pods. To enable authenticated
communication this image needs a [secret](../../docs/secrets.md) to be mounted at `/etc/apiserver-secret`
with the basic authentication username and password.
Here is an example replication controller specification that creates 4 instances of Elasticsearch which is in the file
[music-rc.yaml](music-rc.yaml).
```
apiVersion: v1
kind: ReplicationController
metadata:
labels:
name: music-db
namespace: mytunes
name: music-db
spec:
replicas: 4
selector:
name: music-db
template:
metadata:
labels:
name: music-db
spec:
containers:
- name: es
image: kubernetes/elasticsearch:1.0
env:
- name: "CLUSTER_NAME"
value: "mytunes-db"
- name: "SELECTOR"
value: "name=music-db"
- name: "NAMESPACE"
value: "mytunes"
ports:
- name: es
containerPort: 9200
- name: es-transport
containerPort: 9300
volumeMounts:
- name: apiserver-secret
mountPath: /etc/apiserver-secret
readOnly: true
volumes:
- name: apiserver-secret
secret:
secretName: apiserver-secret
```
The `CLUSTER_NAME` variable gives a name to the cluster and allows multiple separate clusters to
exist in the same namespace.
The `SELECTOR` variable should be set to a label query that identifies the Elasticsearch
nodes that should participate in this cluster. For our example we specify `name=music-db` to
match all pods that have the label `name` set to the value `music-db`.
The `NAMESPACE` variable identifies the namespace
to be used to search for Elasticsearch pods and this should be the same as the namespace specified
for the replication controller (in this case `mytunes`).
Before creating pods with the replication controller a secret containing the bearer authentication token
should be set up. A template is provided in the file [apiserver-secret.yaml](apiserver-secret.yaml):
```
apiVersion: v1
kind: Secret
metadata:
name: apiserver-secret
namespace: NAMESPACE
data:
token: "TOKEN"
```
Replace `NAMESPACE` with the actual namespace to be used and `TOKEN` with the basic64 encoded
versions of the bearer token reported by `kubectl config view` e.g.
```
$ kubectl config view
...
- name: kubernetes-logging_kubernetes-basic-auth
...
token: yGlDcMvSZPX4PyP0Q5bHgAYgi1iyEHv2
...
$ echo yGlDcMvSZPX4PyP0Q5bHgAYgi1iyEHv2 | base64
eUdsRGNNdlNaUFg0UHlQMFE1YkhnQVlnaTFpeUVIdjIK=
```
resulting in the file:
```
apiVersion: v1
kind: Secret
metadata:
name: apiserver-secret
namespace: mytunes
data:
token: "eUdsRGNNdlNaUFg0UHlQMFE1YkhnQVlnaTFpeUVIdjIK="
```
which can be used to create the secret in your namespace:
```
kubectl create -f apiserver-secret.yaml --namespace=mytunes
secrets/apiserver-secret
```
Now you are ready to create the replication controller which will then create the pods:
```
$ kubectl create -f music-rc.yaml --namespace=mytunes
replicationcontrollers/music-db
```
It's also useful to have a [service](../../docs/services.md) with an load balancer for accessing the Elasticsearch
cluster which can be found in the file [music-service.yaml](music-service.yaml).
```
apiVersion: v1
kind: Service
metadata:
name: music-server
namespace: mytunes
labels:
name: music-db
spec:
selector:
name: music-db
ports:
- name: db
port: 9200
targetPort: es
type: LoadBalancer
```
Let's create the service with an external load balancer:
```
$ kubectl create -f music-service.yaml --namespace=mytunes
services/music-server
```
Let's see what we've got:
```
$ kubectl get pods,rc,services,secrets --namespace=mytunes
POD IP CONTAINER(S) IMAGE(S) HOST LABELS STATUS CREATED MESSAGE
music-db-0fwsu 10.244.2.48 kubernetes-minion-m49b/104.197.35.221 name=music-db Running 6 minutes
es kubernetes/elasticsearch:1.0 Running 29 seconds
music-db-5pc2e 10.244.0.24 kubernetes-minion-3c8c/146.148.41.184 name=music-db Running 6 minutes
es kubernetes/elasticsearch:1.0 Running 6 minutes
music-db-bjqmv 10.244.3.31 kubernetes-minion-zey5/104.154.59.10 name=music-db Running 6 minutes
es kubernetes/elasticsearch:1.0 Running 19 seconds
music-db-swtrs 10.244.1.37 kubernetes-minion-f9dw/130.211.159.230 name=music-db Running 6 minutes
es kubernetes/elasticsearch:1.0 Running 6 minutes
CONTROLLER CONTAINER(S) IMAGE(S) SELECTOR REPLICAS
music-db es kubernetes/elasticsearch:1.0 name=music-db 4
NAME LABELS SELECTOR IP(S) PORT(S)
music-server name=music-db name=music-db 10.0.138.61 9200/TCP
104.197.12.157
NAME TYPE DATA
apiserver-secret Opaque 2
```
This shows 4 instances of Elasticsearch running. After making sure that port 9200 is accessible for this cluster (e.g. using a firewall rule for GCE) we can make queries via the service which will be fielded by the matching Elasticsearch pods.
```
$ curl 104.197.12.157:9200
{
"status" : 200,
"name" : "Warpath",
"cluster_name" : "mytunes-db",
"version" : {
"number" : "1.5.2",
"build_hash" : "62ff9868b4c8a0c45860bebb259e21980778ab1c",
"build_timestamp" : "2015-04-27T09:21:06Z",
"build_snapshot" : false,
"lucene_version" : "4.10.4"
},
"tagline" : "You Know, for Search"
}
$ curl 104.197.12.157:9200
{
"status" : 200,
"name" : "Callisto",
"cluster_name" : "mytunes-db",
"version" : {
"number" : "1.5.2",
"build_hash" : "62ff9868b4c8a0c45860bebb259e21980778ab1c",
"build_timestamp" : "2015-04-27T09:21:06Z",
"build_snapshot" : false,
"lucene_version" : "4.10.4"
},
"tagline" : "You Know, for Search"
}
```
We can query the nodes to confirm that an Elasticsearch cluster has been formed.
```
$ curl 104.197.12.157:9200/_nodes?pretty=true
{
"cluster_name" : "mytunes-db",
"nodes" : {
"u-KrvywFQmyaH5BulSclsA" : {
"name" : "Jonas Harrow",
...
"discovery" : {
"zen" : {
"ping" : {
"unicast" : {
"hosts" : [ "10.244.2.48", "10.244.0.24", "10.244.3.31", "10.244.1.37" ]
},
...
"name" : "Warpath",
...
"discovery" : {
"zen" : {
"ping" : {
"unicast" : {
"hosts" : [ "10.244.2.48", "10.244.0.24", "10.244.3.31", "10.244.1.37" ]
},
...
"name" : "Callisto",
...
"discovery" : {
"zen" : {
"ping" : {
"unicast" : {
"hosts" : [ "10.244.2.48", "10.244.0.24", "10.244.3.31", "10.244.1.37" ]
},
...
"name" : "Vapor",
...
"discovery" : {
"zen" : {
"ping" : {
"unicast" : {
"hosts" : [ "10.244.2.48", "10.244.0.24", "10.244.3.31", "10.244.1.37" ]
...
```
Let's ramp up the number of Elasticsearch nodes from 4 to 10:
```
$ kubectl scale --replicas=10 replicationcontrollers music-db --namespace=mytunes
scaled
$ kubectl get pods --namespace=mytunes
POD IP CONTAINER(S) IMAGE(S) HOST LABELS STATUS CREATED MESSAGE
music-db-0fwsu 10.244.2.48 kubernetes-minion-m49b/104.197.35.221 name=music-db Running 33 minutes
es kubernetes/elasticsearch:1.0 Running 26 minutes
music-db-2erje 10.244.2.50 kubernetes-minion-m49b/104.197.35.221 name=music-db Running 48 seconds
es kubernetes/elasticsearch:1.0 Running 46 seconds
music-db-5pc2e 10.244.0.24 kubernetes-minion-3c8c/146.148.41.184 name=music-db Running 33 minutes
es kubernetes/elasticsearch:1.0 Running 32 minutes
music-db-8rkvp 10.244.3.33 kubernetes-minion-zey5/104.154.59.10 name=music-db Running 48 seconds
es kubernetes/elasticsearch:1.0 Running 46 seconds
music-db-bjqmv 10.244.3.31 kubernetes-minion-zey5/104.154.59.10 name=music-db Running 33 minutes
es kubernetes/elasticsearch:1.0 Running 26 minutes
music-db-efc46 10.244.2.49 kubernetes-minion-m49b/104.197.35.221 name=music-db Running 48 seconds
es kubernetes/elasticsearch:1.0 Running 46 seconds
music-db-fhqyg 10.244.0.25 kubernetes-minion-3c8c/146.148.41.184 name=music-db Running 48 seconds
es kubernetes/elasticsearch:1.0 Running 47 seconds
music-db-guxe4 10.244.3.32 kubernetes-minion-zey5/104.154.59.10 name=music-db Running 48 seconds
es kubernetes/elasticsearch:1.0 Running 46 seconds
music-db-pbiq1 10.244.1.38 kubernetes-minion-f9dw/130.211.159.230 name=music-db Running 48 seconds
es kubernetes/elasticsearch:1.0 Running 47 seconds
music-db-swtrs 10.244.1.37 kubernetes-minion-f9dw/130.211.159.230 name=music-db Running 33 minutes
es kubernetes/elasticsearch:1.0 Running 32 minutes
```
Let's check to make sure that these 10 nodes are part of the same Elasticsearch cluster:
```
$ curl 104.197.12.157:9200/_nodes?pretty=true | grep name
"cluster_name" : "mytunes-db",
"name" : "Killraven",
"name" : "Killraven",
"name" : "mytunes-db"
"vm_name" : "OpenJDK 64-Bit Server VM",
"name" : "eth0",
"name" : "Tefral the Surveyor",
"name" : "Tefral the Surveyor",
"name" : "mytunes-db"
"vm_name" : "OpenJDK 64-Bit Server VM",
"name" : "eth0",
"name" : "Jonas Harrow",
"name" : "Jonas Harrow",
"name" : "mytunes-db"
"vm_name" : "OpenJDK 64-Bit Server VM",
"name" : "eth0",
"name" : "Warpath",
"name" : "Warpath",
"name" : "mytunes-db"
"vm_name" : "OpenJDK 64-Bit Server VM",
"name" : "eth0",
"name" : "Brute I",
"name" : "Brute I",
"name" : "mytunes-db"
"vm_name" : "OpenJDK 64-Bit Server VM",
"name" : "eth0",
"name" : "Callisto",
"name" : "Callisto",
"name" : "mytunes-db"
"vm_name" : "OpenJDK 64-Bit Server VM",
"name" : "eth0",
"name" : "Vapor",
"name" : "Vapor",
"name" : "mytunes-db"
"vm_name" : "OpenJDK 64-Bit Server VM",
"name" : "eth0",
"name" : "Timeslip",
"name" : "Timeslip",
"name" : "mytunes-db"
"vm_name" : "OpenJDK 64-Bit Server VM",
"name" : "eth0",
"name" : "Magik",
"name" : "Magik",
"name" : "mytunes-db"
"vm_name" : "OpenJDK 64-Bit Server VM",
"name" : "eth0",
"name" : "Brother Voodoo",
"name" : "Brother Voodoo",
"name" : "mytunes-db"
"vm_name" : "OpenJDK 64-Bit Server VM",
"name" : "eth0",
```
[]()
[]()
| aaronlevy/kubernetes | release-0.20.0/examples/elasticsearch/README.md | Markdown | apache-2.0 | 14,110 | [
30522,
1001,
21274,
17310,
11140,
2005,
13970,
5677,
7159,
2229,
2023,
14176,
3397,
1996,
3120,
2005,
1037,
8946,
2121,
3746,
2008,
9005,
2019,
6013,
1997,
1031,
21274,
17310,
11140,
1033,
1006,
16770,
1024,
1013,
1013,
7479,
1012,
21274,
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
/**
* @package tikiwiki
*/
// (c) Copyright 2002-2013 by authors of the Tiki Wiki CMS Groupware Project
//
// All Rights Reserved. See copyright.txt for details and a complete list of authors.
// Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See license.txt for details.
// $Id: categorize.php 44444 2013-01-05 21:24:24Z changi67 $
require_once('tiki-setup.php');
$access = TikiLib::lib('access');
$access->check_script($_SERVER["SCRIPT_NAME"], basename(__FILE__));
$smarty = TikiLib::lib('smarty');
global $prefs;
$catobjperms = Perms::get(array( 'type' => $cat_type, 'object' => $cat_objid ));
if ($prefs['feature_categories'] == 'y' && $catobjperms->modify_object_categories ) {
$categlib = TikiLib::lib('categ');
if (isset($_REQUEST['import']) and isset($_REQUEST['categories'])) {
$_REQUEST["cat_categories"] = explode(',', $_REQUEST['categories']);
$_REQUEST["cat_categorize"] = 'on';
}
if ( !isset($_REQUEST["cat_categorize"]) || $_REQUEST["cat_categorize"] != 'on' ) {
$_REQUEST['cat_categories'] = NULL;
}
$categlib->update_object_categories(isset($_REQUEST['cat_categories'])?$_REQUEST['cat_categories']:'', $cat_objid, $cat_type, $cat_desc, $cat_name, $cat_href, $_REQUEST['cat_managed']);
}
| reneejustrenee/tikiwikitest | categorize.php | PHP | lgpl-2.1 | 1,238 | [
30522,
1026,
1029,
25718,
1013,
1008,
1008,
1008,
1030,
7427,
14841,
3211,
9148,
3211,
1008,
1013,
1013,
1013,
1006,
1039,
1007,
9385,
2526,
1011,
2286,
2011,
6048,
1997,
1996,
14841,
3211,
15536,
3211,
4642,
2015,
2177,
8059,
2622,
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... |
// Replacement for jquery.ui.accordion to avoid dealing with
// jquery.ui theming.
//
// Usage: $('#container').squeezebox(options);
// where the direct child elements of '#container' are
// sequential pairs of header/panel elements, and options
// is an optional object with any of the following properties:
//
// activeHeaderClass: Class name to apply to the active header
// headerSelector: Selector for the header elements
// nextPanelSelector: Selector for the next panel from a header
// speed: Animation speed
(function($) {
$.fn.squeezebox = function(options) {
// Default options.
options = $.extend({
activeHeaderClass: 'squeezebox-header-on',
headerSelector: '> *:even',
nextPanelSelector: ':first',
speed: 500
}, options);
var headers = this.find(options.headerSelector);
// When a header is clicked, iterate through each of the
// headers, getting their corresponding panels, and opening
// the panel for the header that was clicked (slideDown),
// closing the others (slideUp).
headers.click(function() {
var clicked = this;
$.each(headers, function(i, header) {
var panel = $(header).next(options.nextPanelSelector);
if (clicked == header) {
panel.slideDown(options.speed);
$(header).addClass(options.activeHeaderClass);
} else {
panel.slideUp(options.speed);
$(header).removeClass(options.activeHeaderClass);
}
});
});
};
})(jQuery); | stephenmcd/jquery-squeezebox | jquery.squeezebox.js | JavaScript | bsd-3-clause | 1,697 | [
30522,
1013,
1013,
6110,
2005,
1046,
4226,
2854,
1012,
21318,
1012,
19060,
2000,
4468,
7149,
2007,
1013,
1013,
1046,
4226,
2854,
1012,
21318,
2068,
2075,
1012,
1013,
1013,
1013,
1013,
8192,
1024,
1002,
1006,
1005,
1001,
11661,
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... |
/*
* @brief This file contains USB HID Keyboard example using USB ROM Drivers.
*
* @note
* Copyright(C) NXP Semiconductors, 2013
* All rights reserved.
*
* @par
* Software that is described herein is for illustrative purposes only
* which provides customers with programming information regarding the
* LPC products. This software is supplied "AS IS" without any warranties of
* any kind, and NXP Semiconductors and its licensor disclaim any and
* all warranties, express or implied, including all implied warranties of
* merchantability, fitness for a particular purpose and non-infringement of
* intellectual property rights. NXP Semiconductors assumes no responsibility
* or liability for the use of the software, conveys no license or rights under any
* patent, copyright, mask work right, or any other intellectual property rights in
* or to any products. NXP Semiconductors reserves the right to make changes
* in the software without notification. NXP Semiconductors also makes no
* representation or warranty that such application will be suitable for the
* specified use without further testing or modification.
*
* @par
* Permission to use, copy, modify, and distribute this software and its
* documentation is hereby granted, under NXP Semiconductors' and its
* licensor's relevant copyrights in the software, without fee, provided that it
* is used in conjunction with NXP Semiconductors microcontrollers. This
* copyright, permission, and disclaimer notice must appear in all copies of
* this code.
*/
#include "board.h"
#include <stdint.h>
#include <string.h>
#include "usbd_rom_api.h"
#include "hid_keyboard.h"
#include "ms_timer.h"
/*****************************************************************************
* Private types/enumerations/variables
****************************************************************************/
/**
* @brief Structure to hold Keyboard data
*/
typedef struct {
USBD_HANDLE_T hUsb; /*!< Handle to USB stack. */
uint8_t report[KEYBOARD_REPORT_SIZE]; /*!< Last report data */
uint8_t tx_busy; /*!< Flag indicating whether a report is pending in endpoint queue. */
ms_timer_t tmo; /*!< Timer to track when to send next report. */
} Keyboard_Ctrl_T;
/** Singleton instance of Keyboard control */
static Keyboard_Ctrl_T g_keyBoard;
/*****************************************************************************
* Public types/enumerations/variables
****************************************************************************/
extern const uint8_t Keyboard_ReportDescriptor[];
extern const uint16_t Keyboard_ReportDescSize;
/*****************************************************************************
* Private functions
****************************************************************************/
/* Routine to update keyboard state */
static void Keyboard_UpdateReport(void)
{
uint8_t joystick_status = Joystick_GetStatus();
HID_KEYBOARD_CLEAR_REPORT(&g_keyBoard.report[0]);
switch (joystick_status) {
case JOY_PRESS:
HID_KEYBOARD_REPORT_SET_KEY_PRESS(g_keyBoard.report, 0x53);
break;
case JOY_LEFT:
HID_KEYBOARD_REPORT_SET_KEY_PRESS(g_keyBoard.report, 0x5C);
break;
case JOY_RIGHT:
HID_KEYBOARD_REPORT_SET_KEY_PRESS(g_keyBoard.report, 0x5E);
break;
case JOY_UP:
HID_KEYBOARD_REPORT_SET_KEY_PRESS(g_keyBoard.report, 0x60);
break;
case JOY_DOWN:
HID_KEYBOARD_REPORT_SET_KEY_PRESS(g_keyBoard.report, 0x5A);
break;
}
}
/* HID Get Report Request Callback. Called automatically on HID Get Report Request */
static ErrorCode_t Keyboard_GetReport(USBD_HANDLE_T hHid,
USB_SETUP_PACKET *pSetup,
uint8_t * *pBuffer,
uint16_t *plength)
{
/* ReportID = SetupPacket.wValue.WB.L; */
switch (pSetup->wValue.WB.H) {
case HID_REPORT_INPUT:
Keyboard_UpdateReport();
memcpy(*pBuffer, &g_keyBoard.report[0], KEYBOARD_REPORT_SIZE);
*plength = KEYBOARD_REPORT_SIZE;
break;
case HID_REPORT_OUTPUT: /* Not Supported */
case HID_REPORT_FEATURE: /* Not Supported */
return ERR_USBD_STALL;
}
return LPC_OK;
}
/* HID Set Report Request Callback. Called automatically on HID Set Report Request */
static ErrorCode_t Keyboard_SetReport(USBD_HANDLE_T hHid, USB_SETUP_PACKET *pSetup, uint8_t * *pBuffer, uint16_t length)
{
/* we will reuse standard EP0Buf */
if (length == 0) {
return LPC_OK;
}
/* ReportID = SetupPacket.wValue.WB.L; */
switch (pSetup->wValue.WB.H) {
case HID_REPORT_OUTPUT:
/* If the USB host tells us to turn on the NUM LOCK LED,
* then turn on LED#2.
*/
if (**pBuffer & 0x01) {
Board_LED_Set(0, 1);
}
else {
Board_LED_Set(0, 0);
}
break;
case HID_REPORT_INPUT: /* Not Supported */
case HID_REPORT_FEATURE: /* Not Supported */
return ERR_USBD_STALL;
}
return LPC_OK;
}
/* HID interrupt IN endpoint handler */
static ErrorCode_t Keyboard_EpIN_Hdlr(USBD_HANDLE_T hUsb, void *data, uint32_t event)
{
switch (event) {
case USB_EVT_IN:
g_keyBoard.tx_busy = 0;
break;
}
return LPC_OK;
}
/*****************************************************************************
* Public functions
****************************************************************************/
/* HID keyboard init routine */
ErrorCode_t Keyboard_init(USBD_HANDLE_T hUsb,
USB_INTERFACE_DESCRIPTOR *pIntfDesc,
uint32_t *mem_base,
uint32_t *mem_size)
{
USBD_HID_INIT_PARAM_T hid_param;
USB_HID_REPORT_T reports_data[1];
ErrorCode_t ret = LPC_OK;
/* Do a quick check of if the interface descriptor passed is the right one. */
if ((pIntfDesc == 0) || (pIntfDesc->bInterfaceClass != USB_DEVICE_CLASS_HUMAN_INTERFACE)) {
return ERR_FAILED;
}
/* init joystick control */
Board_Joystick_Init();
/* Init HID params */
memset((void *) &hid_param, 0, sizeof(USBD_HID_INIT_PARAM_T));
hid_param.max_reports = 1;
hid_param.mem_base = *mem_base;
hid_param.mem_size = *mem_size;
hid_param.intf_desc = (uint8_t *) pIntfDesc;
/* user defined functions */
hid_param.HID_GetReport = Keyboard_GetReport;
hid_param.HID_SetReport = Keyboard_SetReport;
hid_param.HID_EpIn_Hdlr = Keyboard_EpIN_Hdlr;
/* Init reports_data */
reports_data[0].len = Keyboard_ReportDescSize;
reports_data[0].idle_time = 0;
reports_data[0].desc = (uint8_t *) &Keyboard_ReportDescriptor[0];
hid_param.report_data = reports_data;
ret = USBD_API->hid->init(hUsb, &hid_param);
/* update memory variables */
*mem_base = hid_param.mem_base;
*mem_size = hid_param.mem_size;
/* store stack handle for later use. */
g_keyBoard.hUsb = hUsb;
/* start the mouse timer */
ms_timerInit(&g_keyBoard.tmo, HID_KEYBRD_REPORT_INTERVAL_MS);
return ret;
}
/* Keyboard tasks */
void Keyboard_Tasks(void)
{
/* check if moue report timer expired */
if (ms_timerExpired(&g_keyBoard.tmo)) {
/* reset timer */
ms_timerStart(&g_keyBoard.tmo);
/* check device is configured before sending report. */
if ( USB_IsConfigured(g_keyBoard.hUsb)) {
/* update report based on board state */
Keyboard_UpdateReport();
/* send report data */
if (g_keyBoard.tx_busy == 0) {
g_keyBoard.tx_busy = 1;
USBD_API->hw->WriteEP(g_keyBoard.hUsb, HID_EP_IN, &g_keyBoard.report[0], KEYBOARD_REPORT_SIZE);
}
}
}
}
| miragecentury/M2_SE_RTOS_Project | Project/LPC1549_Keil/examples/usbd_rom/usbd_rom_hid_keyboard/hid_keyboard.c | C | mit | 7,219 | [
30522,
1013,
1008,
1008,
1030,
4766,
2023,
5371,
3397,
18833,
11041,
9019,
2742,
2478,
18833,
17083,
6853,
1012,
1008,
1008,
1030,
3602,
1008,
9385,
1006,
1039,
1007,
1050,
2595,
2361,
20681,
2015,
1010,
2286,
1008,
2035,
2916,
9235,
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... |
(function(DOM, COMPONENT_CLASS) {
"use strict";
if ("orientation" in window) return; // skip mobile/tablet browsers
// polyfill timeinput for desktop browsers
var htmlEl = DOM.find("html"),
timeparts = function(str) {
str = str.split(":");
if (str.length === 2) {
str[0] = parseFloat(str[0]);
str[1] = parseFloat(str[1]);
} else {
str = [];
}
return str;
},
zeropad = function(value) { return ("00" + value).slice(-2) },
ampm = function(pos, neg) { return htmlEl.get("lang") === "en-US" ? pos : neg },
formatISOTime = function(hours, minutes, ampm) {
return zeropad(ampm === "PM" ? hours + 12 : hours) + ":" + zeropad(minutes);
};
DOM.extend("input[type=time]", {
constructor: function() {
var timeinput = DOM.create("input[type=hidden name=${name}]", {name: this.get("name")}),
ampmspan = DOM.create("span.${c}-meridian>(select>option>{AM}^option>{PM})+span>{AM}", {c: COMPONENT_CLASS}),
ampmselect = ampmspan.child(0);
this
// drop native implementation and clear name attribute
.set({type: "text", maxlength: 5, name: null})
.addClass(COMPONENT_CLASS)
.on("change", this.onChange.bind(this, timeinput, ampmselect))
.on("keydown", this.onKeydown, ["which", "shiftKey"])
.after(ampmspan, timeinput);
ampmselect.on("change", this.onMeridianChange.bind(this, timeinput, ampmselect));
// update value correctly on form reset
this.parent("form").on("reset", this.onFormReset.bind(this, timeinput, ampmselect));
// patch set method to update visible input as well
timeinput.set = this.onValueChanged.bind(this, timeinput.set, timeinput, ampmselect);
// update hidden input value and refresh all visible controls
timeinput.set(this.get()).data("defaultValue", timeinput.get());
// update default values to be formatted
this.set("defaultValue", this.get());
ampmselect.next().data("defaultValue", ampmselect.get());
if (this.matches(":focus")) timeinput.fire("focus");
},
onValueChanged: function(setter, timeinput, ampmselect) {
var parts, hours, minutes;
setter.apply(timeinput, Array.prototype.slice.call(arguments, 3));
if (arguments.length === 4) {
parts = timeparts(timeinput.get());
hours = parts[0];
minutes = parts[1];
// select appropriate AM/PM
ampmselect.child((hours -= 12) > 0 ? 1 : Math.min(hours += 12, 0)).set("selected", true);
// update displayed AM/PM
ampmselect.next().set(ampmselect.get());
// update visible input value, need to add zero padding to minutes
this.set(hours < ampm(13, 24) && minutes < 60 ? hours + ":" + zeropad(minutes) : "");
}
return timeinput;
},
onKeydown: function(which, shiftKey) {
return which === 186 && shiftKey || which < 58;
},
onChange: function(timeinput, ampmselect) {
var parts = timeparts(this.get()),
hours = parts[0],
minutes = parts[1],
value = "";
if (hours < ampm(13, 24) && minutes < 60) {
// refresh hidden input with new value
value = formatISOTime(hours, minutes, ampmselect.get());
} else if (parts.length === 2) {
// restore previous valid value
value = timeinput.get();
}
timeinput.set(value);
},
onMeridianChange: function(timeinput, ampmselect) {
// update displayed AM/PM
ampmselect.next().set(ampmselect.get());
// adjust time in hidden input
timeinput.set(function(el) {
var parts = timeparts(el.get()),
hours = parts[0],
minutes = parts[1];
if (ampmselect.get() === "AM") hours -= 12;
return formatISOTime(hours, minutes, ampmselect.get());
});
},
onFormReset: function(timeinput, ampmselect) {
timeinput.set(timeinput.data("defaultValue"));
ampmselect.next().set(ampmselect.data("defaultValue"));
}
});
}(window.DOM, "better-timeinput"));
| chemerisuk/better-timeinput-polyfill | src/better-timeinput-polyfill.js | JavaScript | mit | 4,655 | [
30522,
1006,
3853,
1006,
14383,
1010,
6922,
1035,
2465,
1007,
1063,
1000,
2224,
9384,
1000,
1025,
2065,
1006,
1000,
10296,
1000,
1999,
3332,
1007,
2709,
1025,
1013,
1013,
13558,
4684,
1013,
13855,
16602,
2015,
1013,
1013,
26572,
8873,
3363,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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.baderlab.autoannotate.internal;
public class Setting<T> {
// Note: WarnDialog settings are in WarnDialogModule
public final static Setting<Boolean> OVERRIDE_GROUP_LABELS = new Setting<Boolean>("overrideGroupLabels", Boolean.class, true);
public final static Setting<Boolean> USE_EASY_MODE = new Setting<Boolean>("useEasyMode", Boolean.class, true);
private final String key;
private final Class<T> type;
private final T defaultValue;
private Setting(String key, Class<T> type, T defaultValue) {
this.key = key;
this.type = type;
this.defaultValue = defaultValue;
}
public String getKey() {
return key;
}
public Class<T> getType() {
return type;
}
public T getDefaultValue() {
return defaultValue;
}
}
| BaderLab/AutoAnnotateApp | AutoAnnotate/src/main/java/org/baderlab/autoannotate/internal/Setting.java | Java | lgpl-2.1 | 751 | [
30522,
7427,
8917,
1012,
2919,
2121,
20470,
1012,
8285,
11639,
17287,
2618,
1012,
4722,
1025,
2270,
2465,
4292,
1026,
1056,
1028,
1063,
1013,
1013,
3602,
1024,
11582,
27184,
8649,
10906,
2024,
1999,
11582,
27184,
8649,
5302,
8566,
2571,
227... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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.ignite.internal.processors.metastorage.persistence;
import java.io.Serializable;
/** */
@SuppressWarnings("PublicField")
class DistributedMetaStorageClusterNodeData implements Serializable {
/** */
private static final long serialVersionUID = 0L;
/** */
public final DistributedMetaStorageVersion ver;
/** */
public final DistributedMetaStorageHistoryItem[] fullData;
/** */
public final DistributedMetaStorageHistoryItem[] hist;
/** */
public DistributedMetaStorageHistoryItem[] updates;
/** */
public DistributedMetaStorageClusterNodeData(
DistributedMetaStorageVersion ver,
DistributedMetaStorageHistoryItem[] fullData,
DistributedMetaStorageHistoryItem[] hist,
DistributedMetaStorageHistoryItem[] updates
) {
this.fullData = fullData;
this.ver = ver;
this.hist = hist;
this.updates = updates;
}
}
| ptupitsyn/ignite | modules/core/src/main/java/org/apache/ignite/internal/processors/metastorage/persistence/DistributedMetaStorageClusterNodeData.java | Java | apache-2.0 | 1,751 | [
30522,
1013,
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,
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 com.kingothepig.tutorialmod.creativetab;
import com.kingothepig.tutorialmod.init.ModItems;
import com.kingothepig.tutorialmod.reference.Reference;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.Item;
public class CreativeTabMod {
public static final CreativeTabs MOD_TAB = new CreativeTabs(Reference.MOD_ID.toLowerCase()){
@Override
public Item getTabIconItem(){
return ModItems.mapleLeaf;
}
};
}
| KingOThePig/TutorialMod | src/main/java/com/kingothepig/tutorialmod/creativetab/CreativeTabMod.java | Java | gpl-3.0 | 477 | [
30522,
7427,
4012,
1012,
2332,
14573,
13699,
8004,
1012,
14924,
4818,
5302,
2094,
1012,
5541,
2696,
2497,
1025,
12324,
4012,
1012,
2332,
14573,
13699,
8004,
1012,
14924,
4818,
5302,
2094,
1012,
1999,
4183,
1012,
16913,
4221,
5244,
1025,
123... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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.archeo4j.core.analyzer;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import javassist.ByteArrayClassPath;
import javassist.CannotCompileException;
import javassist.ClassPool;
import javassist.CtClass;
import javassist.CtMethod;
import javassist.NotFoundException;
import javassist.bytecode.AnnotationsAttribute;
import javassist.bytecode.annotation.Annotation;
import javassist.expr.ExprEditor;
import javassist.expr.MethodCall;
import org.archeo4j.core.model.AnalyzedAnnotation;
import org.archeo4j.core.model.AnalyzedClass;
import org.archeo4j.core.model.AnalyzedMethod;
public class ClassAnalyzer {
private AnalyzisConfig analyzisConfig;
public ClassAnalyzer(AnalyzisConfig analyzisConfig) {
this.analyzisConfig = analyzisConfig;
}
public AnalyzedClass analyzeCallsForClass(String className, byte[] classBytes, String location) {
if (!analyzisConfig.classFilter().test(className))
return null;
AnalyzedClass analyzedClass = new AnalyzedClass(className);
ClassPool cp = new ClassPool();
CtClass ctClass = parseClassByteCode(className, classBytes, cp);
analyzeClassAnnotations(analyzedClass, ctClass);
analyzeInterfaces(analyzedClass, ctClass);
try {
CtMethod[] methods = ctClass.getDeclaredMethods();
for (CtMethod ctMethod : methods) {
AnalyzedMethod method = analyzeMethodCalls(ctMethod);
analyzeMethodAnnotations(method, ctMethod);
analyzedClass.addAnalyzedMethod(method);
}
} catch (RuntimeException e) {
System.out.println("WARN !! failed to analyze " + className + " " + e.getMessage());
}
return analyzedClass;
}
private void analyzeInterfaces(AnalyzedClass analyzedClass, CtClass ctClass) {
analyzedClass.setInterfaceNames(Arrays.asList(ctClass.getClassFile2().getInterfaces()));
analyzedClass.setSuperClassName(ctClass.getClassFile2().getSuperclass());
}
private void analyzeClassAnnotations(AnalyzedClass analyzedClass, CtClass ctClass) {
List<AnalyzedAnnotation> annotations = new ArrayList<>();
for (Object o : ctClass.getClassFile2().getAttributes()) {
if (o instanceof AnnotationsAttribute) {
AnnotationsAttribute attribute = (AnnotationsAttribute) o;
for (Annotation analyzedAnnotation : attribute.getAnnotations()) {
annotations.add(new AnalyzedAnnotation(analyzedAnnotation.toString()));
}
}
}
analyzedClass.setAnnotations(annotations);
}
private void analyzeMethodAnnotations(AnalyzedMethod method, CtMethod ctMethod) {
List<AnalyzedAnnotation> annotations = new ArrayList<>();
for (Object o : ctMethod.getMethodInfo().getAttributes()) {
if (o instanceof AnnotationsAttribute) {
AnnotationsAttribute attribute = (AnnotationsAttribute) o;
annotations.add(new AnalyzedAnnotation(attribute.toString()));
}
}
method.setAnnotations(annotations);
}
private CtClass parseClassByteCode(String className, byte[] classBytes, ClassPool cp) {
cp.appendClassPath(new ByteArrayClassPath(className, classBytes));
CtClass ctClass;
try {
ctClass = cp.get(className);
} catch (NotFoundException e1) {
throw new RuntimeException(e1);
}
return ctClass;
}
private AnalyzedMethod analyzeMethodCalls(CtMethod ctMethod) {
final List<AnalyzedMethod> methodsCalled = new ArrayList<AnalyzedMethod>();
try {
ctMethod.instrument(new ExprEditor() {
@Override
public void edit(MethodCall m) throws CannotCompileException {
if (analyzisConfig.classFilter().test(m.getClassName())) {
methodsCalled.add(asAnalyzedMethod(m));
}
}
});
} catch (CannotCompileException e) {
throw new RuntimeException(e);
}
AnalyzedMethod method = asAnalyzedMethod(ctMethod);
method.setCalledMethods(methodsCalled);
return method;
}
private static AnalyzedMethod asAnalyzedMethod(CtMethod ctMethod) {
String params =
(ctMethod.getLongName().replace(ctMethod.getDeclaringClass().getName(), "").replace("."
+ ctMethod.getName(), ""));
return new AnalyzedMethod(ctMethod.getDeclaringClass().getName(), ctMethod.getName(),
ctMethod.getGenericSignature() != null ? ctMethod.getGenericSignature()
: ctMethod.getSignature(), params, ctMethod.getModifiers());
}
private static AnalyzedMethod asAnalyzedMethod(MethodCall m) {
return new AnalyzedMethod(m.getClassName(), m.getMethodName(), m.getSignature());
}
}
| mestachs/archeo4j | archeo4j-core/src/main/java/org/archeo4j/core/analyzer/ClassAnalyzer.java | Java | mit | 4,707 | [
30522,
7427,
8917,
1012,
7905,
8780,
2549,
3501,
1012,
4563,
1012,
17908,
2099,
1025,
12324,
9262,
1012,
21183,
4014,
1012,
9140,
9863,
1025,
12324,
9262,
1012,
21183,
4014,
1012,
27448,
1025,
12324,
9262,
1012,
21183,
4014,
1012,
2862,
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... |
# -*- coding: utf-8 -*-
tokens = [
'LPAREN',
'RPAREN',
'LBRACE',
'RBRACE',
'EQUAL',
'DOUBLE_EQUAL',
'NUMBER',
'COMMA',
'VAR_DEFINITION',
'IF',
'ELSE',
'END',
'ID',
'PRINT'
]
t_LPAREN = r"\("
t_RPAREN = r"\)"
t_LBRACE = r"\{"
t_RBRACE = r"\}"
t_EQUAL = r"\="
t_DOUBLE_EQUAL = r"\=\="
def t_NUMBER(token):
r"[0-9]+"
token.value = int(token.value)
return token
t_COMMA = r","
def t_VAR_DEFINITION(token):
r",\sFirst\sof\s(his|her)\sName"
return token
def t_IF(token):
r"I\spromise"
return token
def t_ELSE(token):
r"Mayhaps"
return token
def t_PRINT(token):
r"Hodor"
return token
def t_END(token):
r"And\snow\shis\swatch\sis\sended"
return token
def t_ID(token):
r"[a-zA-Z][_a-zA-Z0-9]*"
return token
t_ignore = " \t"
def t_NEWLINE(token):
r"\n+"
token.lexer.lineno += len(token.value)
def t_IGNORE_COMMENTS(token):
r"//(.*)\n"
token.lexer.lineno += 1
def t_error(token):
raise Exception("Sintax error: Unknown token on line {0}. \"{1}\"".format(token.lineno, token.value.partition("\n")[0]))
| pablogonzalezalba/a-language-of-ice-and-fire | lexer_rules.py | Python | mit | 1,138 | [
30522,
1001,
1011,
1008,
1011,
16861,
1024,
21183,
2546,
1011,
1022,
1011,
1008,
1011,
19204,
2015,
1027,
1031,
1005,
6948,
12069,
2078,
1005,
1010,
1005,
1054,
19362,
2368,
1005,
1010,
1005,
6053,
22903,
1005,
30524,
1010,
1005,
2203,
1005... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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 br.com.vepo.datatransform.model;
import org.springframework.beans.factory.annotation.Autowired;
public abstract class Repository<T> {
@Autowired
protected MongoConnection mongoConnection;
public <V> T find(Class<T> clazz, V key) {
return mongoConnection.getMorphiaDataStore().get(clazz, key);
}
public void persist(T obj) {
mongoConnection.getMorphiaDataStore().save(obj);
}
}
| vepo/data-refine | src/main/java/br/com/vepo/datatransform/model/Repository.java | Java | lgpl-3.0 | 399 | [
30522,
7427,
7987,
1012,
4012,
1012,
2310,
6873,
1012,
2951,
6494,
3619,
14192,
1012,
2944,
1025,
12324,
8917,
1012,
3500,
15643,
6198,
1012,
13435,
1012,
4713,
1012,
5754,
17287,
3508,
1012,
8285,
20357,
2094,
1025,
2270,
10061,
2465,
2240... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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... |
/*
* DBeaver - Universal Database Manager
* Copyright (C) 2010-2017 Serge Rider (serge@jkiss.org)
* Copyright (C) 2011-2012 Eugene Fradkin (eugene.fradkin@gmail.com)
*
* 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.jkiss.dbeaver.ext.oracle.views;
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.widgets.*;
import org.jkiss.dbeaver.core.DBeaverCore;
import org.jkiss.dbeaver.ext.oracle.model.OracleConstants;
import org.jkiss.dbeaver.model.preferences.DBPPreferenceStore;
import org.jkiss.dbeaver.model.DBPDataSourceContainer;
import org.jkiss.dbeaver.ui.UIUtils;
import org.jkiss.dbeaver.ui.preferences.PreferenceStoreDelegate;
import org.jkiss.dbeaver.ui.preferences.TargetPrefPage;
import org.jkiss.dbeaver.utils.PrefUtils;
/**
* PrefPageOracle
*/
public class PrefPageOracle extends TargetPrefPage
{
public static final String PAGE_ID = "org.jkiss.dbeaver.preferences.oracle.general"; //$NON-NLS-1$
private Text explainTableText;
private Button rowidSupportCheck;
private Button enableDbmsOuputCheck;
public PrefPageOracle()
{
super();
setPreferenceStore(new PreferenceStoreDelegate(DBeaverCore.getGlobalPreferenceStore()));
}
@Override
protected boolean hasDataSourceSpecificOptions(DBPDataSourceContainer dataSourceDescriptor)
{
DBPPreferenceStore store = dataSourceDescriptor.getPreferenceStore();
return
store.contains(OracleConstants.PREF_EXPLAIN_TABLE_NAME) ||
store.contains(OracleConstants.PREF_SUPPORT_ROWID) ||
store.contains(OracleConstants.PREF_DBMS_OUTPUT)
;
}
@Override
protected boolean supportsDataSourceSpecificOptions()
{
return true;
}
@Override
protected Control createPreferenceContent(Composite parent)
{
Composite composite = UIUtils.createPlaceholder(parent, 1);
{
Group planGroup = UIUtils.createControlGroup(composite, "Execution plan", 2, GridData.FILL_HORIZONTAL, 0);
Label descLabel = new Label(planGroup, SWT.WRAP);
descLabel.setText("By default plan table in current or SYS schema will be used.\nYou may set some particular fully qualified plan table name here.");
GridData gd = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
gd.horizontalSpan = 2;
descLabel.setLayoutData(gd);
explainTableText = UIUtils.createLabelText(planGroup, "Plan table", "", SWT.BORDER, new GridData(GridData.FILL_HORIZONTAL));
}
{
Group planGroup = UIUtils.createControlGroup(composite, "Misc", 2, GridData.FILL_HORIZONTAL, 0);
rowidSupportCheck = UIUtils.createLabelCheckbox(planGroup, "Use ROWID to identify rows", true);
enableDbmsOuputCheck = UIUtils.createLabelCheckbox(planGroup, "Enable DBMS Output", true);
}
return composite;
}
@Override
protected void loadPreferences(DBPPreferenceStore store)
{
explainTableText.setText(store.getString(OracleConstants.PREF_EXPLAIN_TABLE_NAME));
rowidSupportCheck.setSelection(store.getBoolean(OracleConstants.PREF_SUPPORT_ROWID));
enableDbmsOuputCheck.setSelection(store.getBoolean(OracleConstants.PREF_DBMS_OUTPUT));
}
@Override
protected void savePreferences(DBPPreferenceStore store)
{
store.setValue(OracleConstants.PREF_EXPLAIN_TABLE_NAME, explainTableText.getText());
store.setValue(OracleConstants.PREF_SUPPORT_ROWID, rowidSupportCheck.getSelection());
store.setValue(OracleConstants.PREF_DBMS_OUTPUT, enableDbmsOuputCheck.getSelection());
PrefUtils.savePreferenceStore(store);
}
@Override
protected void clearPreferences(DBPPreferenceStore store)
{
store.setToDefault(OracleConstants.PREF_EXPLAIN_TABLE_NAME);
store.setToDefault(OracleConstants.PREF_SUPPORT_ROWID);
store.setToDefault(OracleConstants.PREF_DBMS_OUTPUT);
}
@Override
protected String getPropertyPageID()
{
return PAGE_ID;
}
} | ruspl-afed/dbeaver | plugins/org.jkiss.dbeaver.ext.oracle/src/org/jkiss/dbeaver/ext/oracle/views/PrefPageOracle.java | Java | apache-2.0 | 4,753 | [
30522,
1013,
1008,
1008,
16962,
5243,
6299,
1011,
5415,
7809,
3208,
1008,
9385,
1006,
1039,
1007,
2230,
1011,
2418,
21747,
7945,
1006,
21747,
1030,
1046,
14270,
2015,
1012,
8917,
1007,
1008,
9385,
1006,
1039,
1007,
2249,
1011,
2262,
8207,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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... |
"use strict";
var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
var Tink = (function () {
function Tink(PIXI, element) {
var scale = arguments.length <= 2 || arguments[2] === undefined ? 1 : arguments[2];
_classCallCheck(this, Tink);
//Add element and scale properties
this.element = element;
this.scale = scale;
//An array to store all the draggable sprites
this.draggableSprites = [];
//An array to store all the pointer objects
//(there will usually just be one)
this.pointers = [];
//An array to store all the buttons and button-like
//interactive sprites
this.buttons = [];
//A local PIXI reference
this.PIXI = PIXI;
//Aliases for Pixi objects
this.TextureCache = this.PIXI.utils.TextureCache;
this.MovieClip = this.PIXI.extras.MovieClip;
this.Texture = this.PIXI.Texture;
}
//`makeDraggable` lets you make a drag-and-drop sprite by pushing it
//into the `draggableSprites` array
_createClass(Tink, [{
key: "makeDraggable",
value: function makeDraggable() {
var _this = this;
for (var _len = arguments.length, sprites = Array(_len), _key = 0; _key < _len; _key++) {
sprites[_key] = arguments[_key];
}
//If the first argument isn't an array of sprites...
if (!(sprites[0] instanceof Array)) {
sprites.forEach(function (sprite) {
_this.draggableSprites.push(sprite);
//If the sprite's `draggable` property hasn't already been defined by
//another library, like Hexi, define it
if (sprite.draggable === undefined) {
sprite.draggable = true;
sprite._localDraggableAllocation = true;
}
});
}
//If the first argument is an array of sprites...
else {
var spritesArray = sprites[0];
if (spritesArray.length > 0) {
for (var i = spritesArray.length - 1; i >= 0; i--) {
var sprite = spritesArray[i];
this.draggableSprites.push(sprite);
//If the sprite's `draggable` property hasn't already been defined by
//another library, like Hexi, define it
if (sprite.draggable === undefined) {
sprite.draggable = true;
sprite._localDraggableAllocation = true;
}
}
}
}
}
//`makeUndraggable` removes the sprite from the `draggableSprites`
//array
}, {
key: "makeUndraggable",
value: function makeUndraggable() {
var _this2 = this;
for (var _len2 = arguments.length, sprites = Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
sprites[_key2] = arguments[_key2];
}
//If the first argument isn't an array of sprites...
if (!(sprites[0] instanceof Array)) {
sprites.forEach(function (sprite) {
_this2.draggableSprites.splice(_this2.draggableSprites.indexOf(sprite), 1);
if (sprite._localDraggableAllocation === true) sprite.draggable = false;
});
}
//If the first argument is an array of sprites
else {
var spritesArray = sprites[0];
if (spritesArray.length > 0) {
for (var i = spritesArray.length - 1; i >= 0; i--) {
var sprite = spritesArray[i];
this.draggableSprites.splice(this.draggableSprites.indexOf(sprite), 1);
if (sprite._localDraggableAllocation === true) sprite.draggable = false;
}
}
}
}
}, {
key: "makePointer",
value: function makePointer() {
var element = arguments.length <= 0 || arguments[0] === undefined ? this.element : arguments[0];
var scale = arguments.length <= 1 || arguments[1] === undefined ? this.scale : arguments[1];
//Get a reference to Tink's global `draggableSprites` array
var draggableSprites = this.draggableSprites;
//Get a reference to Tink's `addGlobalPositionProperties` method
var addGlobalPositionProperties = this.addGlobalPositionProperties;
//The pointer object will be returned by this function
var pointer = {
element: element,
scale: scale,
//Private x and y properties
_x: 0,
_y: 0,
//Width and height
width: 1,
height: 1,
//The public x and y properties are divided by the scale. If the
//HTML element that the pointer is sensitive to (like the canvas)
//is scaled up or down, you can change the `scale` value to
//correct the pointer's position values
get x() {
return this._x / this.scale;
},
get y() {
return this._y / this.scale;
},
//Add `centerX` and `centerY` getters so that we
//can use the pointer's coordinates with easing
//and collision functions
get centerX() {
return this.x;
},
get centerY() {
return this.y;
},
//`position` returns an object with x and y properties that
//contain the pointer's position
get position() {
return {
x: this.x,
y: this.y
};
},
//Add a `cursor` getter/setter to change the pointer's cursor
//style. Values can be "pointer" (for a hand icon) or "auto" for
//an ordinary arrow icon.
get cursor() {
return this.element.style.cursor;
},
set cursor(value) {
this.element.style.cursor = value;
},
//Booleans to track the pointer state
isDown: false,
isUp: true,
tapped: false,
//Properties to help measure the time between up and down states
downTime: 0,
elapsedTime: 0,
//Optional `press`,`release` and `tap` methods
press: undefined,
release: undefined,
tap: undefined,
//A `dragSprite` property to help with drag and drop
dragSprite: null,
//The drag offsets to help drag sprites
dragOffsetX: 0,
dragOffsetY: 0,
//A property to check whether or not the pointer
//is visible
_visible: true,
get visible() {
return this._visible;
},
set visible(value) {
if (value === true) {
this.cursor = "auto";
} else {
this.cursor = "none";
}
this._visible = value;
},
//The pointer's mouse `moveHandler`
moveHandler: function moveHandler(event) {
//Get the element that's firing the event
var element = event.target;
//Find the pointer’s x and y position (for mouse).
//Subtract the element's top and left offset from the browser window
this._x = event.pageX - element.offsetLeft;
this._y = event.pageY - element.offsetTop;
//Prevent the event's default behavior
event.preventDefault();
},
//The pointer's `touchmoveHandler`
touchmoveHandler: function touchmoveHandler(event) {
var element = event.target;
//Find the touch point's x and y position
this._x = event.targetTouches[0].pageX - element.offsetLeft;
this._y = event.targetTouches[0].pageY - element.offsetTop;
event.preventDefault();
},
//The pointer's `downHandler`
downHandler: function downHandler(event) {
//Set the down states
this.isDown = true;
this.isUp = false;
this.tapped = false;
//Capture the current time
this.downTime = Date.now();
//Call the `press` method if it's been assigned
if (this.press) this.press();
event.preventDefault();
},
//The pointer's `touchstartHandler`
touchstartHandler: function touchstartHandler(event) {
var element = event.target;
//Find the touch point's x and y position
this._x = event.targetTouches[0].pageX - element.offsetLeft;
this._y = event.targetTouches[0].pageY - element.offsetTop;
//Set the down states
this.isDown = true;
this.isUp = false;
this.tapped = false;
//Capture the current time
this.downTime = Date.now();
//Call the `press` method if it's been assigned
if (this.press) this.press();
event.preventDefault();
},
//The pointer's `upHandler`
upHandler: function upHandler(event) {
//Figure out how much time the pointer has been down
this.elapsedTime = Math.abs(this.downTime - Date.now());
//If it's less than 200 milliseconds, it must be a tap or click
if (this.elapsedTime <= 200 && this.tapped === false) {
this.tapped = true;
//Call the `tap` method if it's been assigned
if (this.tap) this.tap();
}
this.isUp = true;
this.isDown = false;
//Call the `release` method if it's been assigned
if (this.release) this.release();
event.preventDefault();
},
//The pointer's `touchendHandler`
touchendHandler: function touchendHandler(event) {
//Figure out how much time the pointer has been down
this.elapsedTime = Math.abs(this.downTime - Date.now());
//If it's less than 200 milliseconds, it must be a tap or click
if (this.elapsedTime <= 200 && this.tapped === false) {
this.tapped = true;
//Call the `tap` method if it's been assigned
if (this.tap) this.tap();
}
this.isUp = true;
this.isDown = false;
//Call the `release` method if it's been assigned
if (this.release) this.release();
event.preventDefault();
},
//`hitTestSprite` figures out if the pointer is touching a sprite
hitTestSprite: function hitTestSprite(sprite) {
//Add global `gx` and `gy` properties to the sprite if they
//don't already exist
addGlobalPositionProperties(sprite);
//The `hit` variable will become `true` if the pointer is
//touching the sprite and remain `false` if it isn't
var hit = false;
//Find out the sprite's offset from its anchor point
var xAnchorOffset = undefined,
yAnchorOffset = undefined;
if (sprite.anchor !== undefined) {
xAnchorOffset = sprite.width * sprite.anchor.x;
yAnchorOffset = sprite.height * sprite.anchor.y;
} else {
xAnchorOffset = 0;
yAnchorOffset = 0;
}
//Is the sprite rectangular?
if (!sprite.circular) {
//Get the position of the sprite's edges using global
//coordinates
var left = sprite.gx - xAnchorOffset,
right = sprite.gx + sprite.width - xAnchorOffset,
top = sprite.gy - yAnchorOffset,
bottom = sprite.gy + sprite.height - yAnchorOffset;
//Find out if the pointer is intersecting the rectangle.
//`hit` will become `true` if the pointer is inside the
//sprite's area
hit = this.x > left && this.x < right && this.y > top && this.y < bottom;
}
//Is the sprite circular?
else {
//Find the distance between the pointer and the
//center of the circle
var vx = this.x - (sprite.gx + sprite.width / 2 - xAnchorOffset),
vy = this.y - (sprite.gy + sprite.width / 2 - yAnchorOffset),
distance = Math.sqrt(vx * vx + vy * vy);
//The pointer is intersecting the circle if the
//distance is less than the circle's radius
hit = distance < sprite.width / 2;
}
return hit;
}
};
//Bind the events to the handlers
//Mouse events
element.addEventListener("mousemove", pointer.moveHandler.bind(pointer), false);
element.addEventListener("mousedown", pointer.downHandler.bind(pointer), false);
//Add the `mouseup` event to the `window` to
//catch a mouse button release outside of the canvas area
window.addEventListener("mouseup", pointer.upHandler.bind(pointer), false);
//Touch events
element.addEventListener("touchmove", pointer.touchmoveHandler.bind(pointer), false);
element.addEventListener("touchstart", pointer.touchstartHandler.bind(pointer), false);
//Add the `touchend` event to the `window` object to
//catch a mouse button release outside of the canvas area
window.addEventListener("touchend", pointer.touchendHandler.bind(pointer), false);
//Disable the default pan and zoom actions on the `canvas`
element.style.touchAction = "none";
//Add the pointer to Tink's global `pointers` array
this.pointers.push(pointer);
//Return the pointer
return pointer;
}
//Many of Tink's objects, like pointers, use collision
//detection using the sprites' global x and y positions. To make
//this easier, new `gx` and `gy` properties are added to sprites
//that reference Pixi sprites' `getGlobalPosition()` values.
}, {
key: "addGlobalPositionProperties",
value: function addGlobalPositionProperties(sprite) {
if (sprite.gx === undefined) {
Object.defineProperty(sprite, "gx", {
get: function get() {
return sprite.getGlobalPosition().x;
}
});
}
if (sprite.gy === undefined) {
Object.defineProperty(sprite, "gy", {
get: function get() {
return sprite.getGlobalPosition().y;
}
});
}
}
//A method that implments drag-and-drop functionality
//for each pointer
}, {
key: "updateDragAndDrop",
value: function updateDragAndDrop(draggableSprites) {
//Create a pointer if one doesn't already exist
if (this.pointers.length === 0) {
this.makePointer(this.element, this.scale);
}
//Loop through all the pointers in Tink's global `pointers` array
//(there will usually just be one, but you never know)
this.pointers.forEach(function (pointer) {
//Check whether the pointer is pressed down
if (pointer.isDown) {
//You need to capture the co-ordinates at which the pointer was
//pressed down and find out if it's touching a sprite
//Only run pointer.code if the pointer isn't already dragging
//sprite
if (pointer.dragSprite === null) {
//Loop through the `draggableSprites` in reverse to start searching at the bottom of the stack
for (var i = draggableSprites.length - 1; i > -1; i--) {
//Get a reference to the current sprite
var sprite = draggableSprites[i];
//Check for a collision with the pointer using `hitTestSprite`
if (pointer.hitTestSprite(sprite) && sprite.draggable) {
//Calculate the difference between the pointer's
//position and the sprite's position
pointer.dragOffsetX = pointer.x - sprite.gx;
pointer.dragOffsetY = pointer.y - sprite.gy;
//Set the sprite as the pointer's `dragSprite` property
pointer.dragSprite = sprite;
//The next two lines re-order the `sprites` array so that the
//selected sprite is displayed above all the others.
//First, splice the sprite out of its current position in
//its parent's `children` array
var children = sprite.parent.children;
children.splice(children.indexOf(sprite), 1);
//Next, push the `dragSprite` to the end of its `children` array so that it's
//displayed last, above all the other sprites
children.push(sprite);
//Reorganize the `draggableSpites` array in the same way
draggableSprites.splice(draggableSprites.indexOf(sprite), 1);
draggableSprites.push(sprite);
//Break the loop, because we only need to drag the topmost sprite
break;
}
}
}
//If the pointer is down and it has a `dragSprite`, make the sprite follow the pointer's
//position, with the calculated offset
else {
pointer.dragSprite.x = pointer.x - pointer.dragOffsetX;
pointer.dragSprite.y = pointer.y - pointer.dragOffsetY;
}
}
//If the pointer is up, drop the `dragSprite` by setting it to `null`
if (pointer.isUp) {
pointer.dragSprite = null;
}
//Change the mouse arrow pointer to a hand if it's over a
//draggable sprite
draggableSprites.some(function (sprite) {
if (pointer.hitTestSprite(sprite) && sprite.draggable) {
if (pointer.visible) pointer.cursor = "pointer";
return true;
} else {
if (pointer.visible) pointer.cursor = "auto";
return false;
}
});
});
}
}, {
key: "makeInteractive",
value: function makeInteractive(o) {
//The `press`,`release`, `over`, `out` and `tap` methods. They're `undefined`
//for now, but they can be defined in the game program
o.press = o.press || undefined;
o.release = o.release || undefined;
o.over = o.over || undefined;
o.out = o.out || undefined;
o.tap = o.tap || undefined;
//The `state` property tells you the button's
//current state. Set its initial state to "up"
o.state = "up";
//The `action` property tells you whether its being pressed or
//released
o.action = "";
//The `pressed` and `hoverOver` Booleans are mainly for internal
//use in this code to help figure out the correct state.
//`pressed` is a Boolean that helps track whether or not
//the sprite has been pressed down
o.pressed = false;
//`hoverOver` is a Boolean which checks whether the pointer
//has hovered over the sprite
o.hoverOver = false;
//tinkType is a string that will be set to "button" if the
//user creates an object using the `button` function
o.tinkType = "";
//Set `enabled` to true to allow for interactivity
//Set `enabled` to false to disable interactivity
o.enabled = true;
//Add the sprite to the global `buttons` array so that it can
//be updated each frame in the `updateButtons method
this.buttons.push(o);
}
//The `updateButtons` method will be called each frame
//inside the game loop. It updates all the button-like sprites
}, {
key: "updateButtons",
value: function updateButtons() {
var _this3 = this;
//Create a pointer if one doesn't already exist
if (this.pointers.length === 0) {
this.makePointer(this.element, this.scale);
}
//Loop through all the button-like sprites that were created
//using the `makeInteractive` method
this.buttons.forEach(function (o) {
//Only do this if the interactive object is enabled
if (o.enabled) {
//Loop through all of Tink's pointers (there will usually
//just be one)
_this3.pointers.forEach(function (pointer) {
//Figure out if the pointer is touching the sprite
var hit = pointer.hitTestSprite(o);
//1. Figure out the current state
if (pointer.isUp) {
//Up state
o.state = "up";
//Show the first image state frame, if this is a `Button` sprite
if (o.tinkType === "button") o.gotoAndStop(0);
}
//If the pointer is touching the sprite, figure out
//if the over or down state should be displayed
if (hit) {
//Over state
o.state = "over";
//Show the second image state frame if this sprite has
//3 frames and it's a `Button` sprite
if (o.totalFrames && o.totalFrames === 3 && o.tinkType === "button") {
o.gotoAndStop(1);
}
//Down state
if (pointer.isDown) {
o.state = "down";
//Show the third frame if this sprite is a `Button` sprite and it
//has only three frames, or show the second frame if it
//only has two frames
if (o.tinkType === "button") {
if (o.totalFrames === 3) {
o.gotoAndStop(2);
} else {
o.gotoAndStop(1);
}
}
}
//Change the pointer icon to a hand
if (pointer.visible) pointer.cursor = "pointer";
} else {
//Turn the pointer to an ordinary arrow icon if the
//pointer isn't touching a sprite
if (pointer.visible) pointer.cursor = "auto";
}
//Perform the correct interactive action
//a. Run the `press` method if the sprite state is "down" and
//the sprite hasn't already been pressed
if (o.state === "down") {
if (!o.pressed) {
if (o.press) o.press();
o.pressed = true;
o.action = "pressed";
}
}
//b. Run the `release` method if the sprite state is "over" and
//the sprite has been pressed
if (o.state === "over") {
if (o.pressed) {
if (o.release) o.release();
o.pressed = false;
o.action = "released";
//If the pointer was tapped and the user assigned a `tap`
//method, call the `tap` method
if (pointer.tapped && o.tap) o.tap();
}
//Run the `over` method if it has been assigned
if (!o.hoverOver) {
if (o.over) o.over();
o.hoverOver = true;
}
}
//c. Check whether the pointer has been released outside
//the sprite's area. If the button state is "up" and it's
//already been pressed, then run the `release` method.
if (o.state === "up") {
if (o.pressed) {
if (o.release) o.release();
o.pressed = false;
o.action = "released";
}
//Run the `out` method if it has been assigned
if (o.hoverOver) {
if (o.out) o.out();
o.hoverOver = false;
}
}
});
}
});
}
//A function that creates a sprite with 3 frames that
//represent the button states: up, over and down
}, {
key: "button",
value: function button(source) {
var x = arguments.length <= 1 || arguments[1] === undefined ? 0 : arguments[1];
var y = arguments.length <= 2 || arguments[2] === undefined ? 0 : arguments[2];
//The sprite object that will be returned
var o = undefined;
//Is it an array of frame ids or textures?
if (typeof source[0] === "string") {
//They're strings, but are they pre-existing texture or
//paths to image files?
//Check to see if the first element matches a texture in the
//cache
if (this.TextureCache[source[0]]) {
//It does, so it's an array of frame ids
o = this.MovieClip.fromFrames(source);
} else {
//It's not already in the cache, so let's load it
o = this.MovieClip.fromImages(source);
}
}
//If the `source` isn't an array of strings, check whether
//it's an array of textures
else if (source[0] instanceof this.Texture) {
//Yes, it's an array of textures.
//Use them to make a MovieClip o
o = new this.MovieClip(source);
}
//Add interactive properties to the button
this.makeInteractive(o);
//Set the `tinkType` to "button"
o.tinkType = "button";
//Position the button
o.x = x;
o.y = y;
//Return the new button sprite
return o;
}
//Run the `udpate` function in your game loop
//to update all of Tink's interactive objects
}, {
key: "update",
value: function update() {
//Update the drag and drop system
if (this.draggableSprites.length !== 0) this.updateDragAndDrop(this.draggableSprites);
//Update the buttons and button-like interactive sprites
if (this.buttons.length !== 0) this.updateButtons();
}
/*
`keyboard` is a method that listens for and captures keyboard events. It's really
just a convenient wrapper function for HTML `keyup` and `keydown` events so that you can keep your application code clutter-free and easier to write and read.
Here's how to use the `keyboard` method. Create a new keyboard object like this:
```js
let keyObject = keyboard(asciiKeyCodeNumber);
```
It's one argument is the ASCII key code number of the keyboard key
that you want to listen for. [Here's a list of ASCII key codes you can
use](http://www.asciitable.com).
Then assign `press` and `release` methods to the keyboard object like this:
```js
keyObject.press = () => {
//key object pressed
};
keyObject.release = () => {
//key object released
};
```
Keyboard objects also have `isDown` and `isUp` Boolean properties that you can use to check the state of each key.
*/
}, {
key: "keyboard",
value: function keyboard(keyCode) {
var key = {};
key.code = keyCode;
key.isDown = false;
key.isUp = true;
key.press = undefined;
key.release = undefined;
//The `downHandler`
key.downHandler = function (event) {
if (event.keyCode === key.code) {
if (key.isUp && key.press) key.press();
key.isDown = true;
key.isUp = false;
}
event.preventDefault();
};
//The `upHandler`
key.upHandler = function (event) {
if (event.keyCode === key.code) {
if (key.isDown && key.release) key.release();
key.isDown = false;
key.isUp = true;
}
event.preventDefault();
};
//Attach event listeners
window.addEventListener("keydown", key.downHandler.bind(key), false);
window.addEventListener("keyup", key.upHandler.bind(key), false);
//Return the key object
return key;
}
//`arrowControl` is a convenience method for updating a sprite's velocity
//for 4-way movement using the arrow directional keys. Supply it
//with the sprite you want to control and the speed per frame, in
//pixels, that you want to update the sprite's velocity
}, {
key: "arrowControl",
value: function arrowControl(sprite, speed) {
if (speed === undefined) {
throw new Error("Please supply the arrowControl method with the speed at which you want the sprite to move");
}
var upArrow = this.keyboard(38),
rightArrow = this.keyboard(39),
downArrow = this.keyboard(40),
leftArrow = this.keyboard(37);
//Assign key `press` methods
leftArrow.press = function () {
//Change the sprite's velocity when the key is pressed
sprite.vx = -speed;
sprite.vy = 0;
};
leftArrow.release = function () {
//If the left arrow has been released, and the right arrow isn't down,
//and the sprite isn't moving vertically:
//Stop the sprite
if (!rightArrow.isDown && sprite.vy === 0) {
sprite.vx = 0;
}
};
upArrow.press = function () {
sprite.vy = -speed;
sprite.vx = 0;
};
upArrow.release = function () {
if (!downArrow.isDown && sprite.vx === 0) {
sprite.vy = 0;
}
};
rightArrow.press = function () {
sprite.vx = speed;
sprite.vy = 0;
};
rightArrow.release = function () {
if (!leftArrow.isDown && sprite.vy === 0) {
sprite.vx = 0;
}
};
downArrow.press = function () {
sprite.vy = speed;
sprite.vx = 0;
};
downArrow.release = function () {
if (!upArrow.isDown && sprite.vx === 0) {
sprite.vy = 0;
}
};
}
}]);
return Tink;
})();
//# sourceMappingURL=tink.js.map | danman113/Bound-Horizon | libs/tink.js | JavaScript | mit | 29,711 | [
30522,
1000,
2224,
9384,
1000,
1025,
13075,
1035,
3443,
26266,
1027,
1006,
3853,
1006,
1007,
1063,
3853,
9375,
21572,
4842,
7368,
1006,
4539,
1010,
24387,
1007,
1063,
2005,
1006,
13075,
1045,
1027,
1014,
1025,
1045,
1026,
24387,
1012,
3091,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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 (version 1.7.0_51) on Thu Apr 28 18:37:57 UTC 2016 -->
<title>Uses of Class org.apache.cassandra.cql3.restrictions.MultiColumnRestriction.IN (apache-cassandra API)</title>
<meta name="date" content="2016-04-28">
<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 org.apache.cassandra.cql3.restrictions.MultiColumnRestriction.IN (apache-cassandra API)";
}
//-->
</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="../../../../../../org/apache/cassandra/cql3/restrictions/MultiColumnRestriction.IN.html" title="class in org.apache.cassandra.cql3.restrictions">Class</a></li>
<li class="navBarCell1Rev">Use</li>
<li><a href="../../../../../../overview-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>
<div class="subNav">
<ul class="navList">
<li>Prev</li>
<li>Next</li>
</ul>
<ul class="navList">
<li><a href="../../../../../../index.html?org/apache/cassandra/cql3/restrictions/class-use/MultiColumnRestriction.IN.html" target="_top">Frames</a></li>
<li><a href="MultiColumnRestriction.IN.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 org.apache.cassandra.cql3.restrictions.MultiColumnRestriction.IN" class="title">Uses of Class<br>org.apache.cassandra.cql3.restrictions.MultiColumnRestriction.IN</h2>
</div>
<div class="classUseContainer">
<ul class="blockList">
<li class="blockList">
<table border="0" cellpadding="3" cellspacing="0" summary="Use table, listing packages, and an explanation">
<caption><span>Packages that use <a href="../../../../../../org/apache/cassandra/cql3/restrictions/MultiColumnRestriction.IN.html" title="class in org.apache.cassandra.cql3.restrictions">MultiColumnRestriction.IN</a></span><span class="tabEnd"> </span></caption>
<tr>
<th class="colFirst" scope="col">Package</th>
<th class="colLast" scope="col">Description</th>
</tr>
<tbody>
<tr class="altColor">
<td class="colFirst"><a href="#org.apache.cassandra.cql3.restrictions">org.apache.cassandra.cql3.restrictions</a></td>
<td class="colLast"> </td>
</tr>
</tbody>
</table>
</li>
<li class="blockList">
<ul class="blockList">
<li class="blockList"><a name="org.apache.cassandra.cql3.restrictions">
<!-- -->
</a>
<h3>Uses of <a href="../../../../../../org/apache/cassandra/cql3/restrictions/MultiColumnRestriction.IN.html" title="class in org.apache.cassandra.cql3.restrictions">MultiColumnRestriction.IN</a> in <a href="../../../../../../org/apache/cassandra/cql3/restrictions/package-summary.html">org.apache.cassandra.cql3.restrictions</a></h3>
<table border="0" cellpadding="3" cellspacing="0" summary="Use table, listing subclasses, and an explanation">
<caption><span>Subclasses of <a href="../../../../../../org/apache/cassandra/cql3/restrictions/MultiColumnRestriction.IN.html" title="class in org.apache.cassandra.cql3.restrictions">MultiColumnRestriction.IN</a> in <a href="../../../../../../org/apache/cassandra/cql3/restrictions/package-summary.html">org.apache.cassandra.cql3.restrictions</a></span><span class="tabEnd"> </span></caption>
<tr>
<th class="colFirst" scope="col">Modifier and Type</th>
<th class="colLast" scope="col">Class and Description</th>
</tr>
<tbody>
<tr class="altColor">
<td class="colFirst"><code>static class </code></td>
<td class="colLast"><code><strong><a href="../../../../../../org/apache/cassandra/cql3/restrictions/MultiColumnRestriction.InWithMarker.html" title="class in org.apache.cassandra.cql3.restrictions">MultiColumnRestriction.InWithMarker</a></strong></code>
<div class="block">An IN restriction that uses a single marker for a set of IN values that are tuples.</div>
</td>
</tr>
<tr class="rowColor">
<td class="colFirst"><code>static class </code></td>
<td class="colLast"><code><strong><a href="../../../../../../org/apache/cassandra/cql3/restrictions/MultiColumnRestriction.InWithValues.html" title="class in org.apache.cassandra.cql3.restrictions">MultiColumnRestriction.InWithValues</a></strong></code>
<div class="block">An IN restriction that has a set of terms for in values.</div>
</td>
</tr>
</tbody>
</table>
</li>
</ul>
</li>
</ul>
</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="../../../../../../org/apache/cassandra/cql3/restrictions/MultiColumnRestriction.IN.html" title="class in org.apache.cassandra.cql3.restrictions">Class</a></li>
<li class="navBarCell1Rev">Use</li>
<li><a href="../../../../../../overview-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>
<div class="subNav">
<ul class="navList">
<li>Prev</li>
<li>Next</li>
</ul>
<ul class="navList">
<li><a href="../../../../../../index.html?org/apache/cassandra/cql3/restrictions/class-use/MultiColumnRestriction.IN.html" target="_top">Frames</a></li>
<li><a href="MultiColumnRestriction.IN.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 ======= -->
<p class="legalCopy"><small>Copyright © 2016 The Apache Software Foundation</small></p>
</body>
</html>
| elisska/cloudera-cassandra | DATASTAX_CASSANDRA-2.2.6/javadoc/org/apache/cassandra/cql3/restrictions/class-use/MultiColumnRestriction.IN.html | HTML | apache-2.0 | 7,347 | [
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... |
import React, { PropTypes } from 'react';
const ProductList = (props) => {
const pl = props.productList;
const products = Object.keys(pl);
return (<ul>
{products.map(key => <li key={key}><a href={`#/product/${key}`} >{pl[key].name}</a></li>)}
</ul>);
};
ProductList.propTypes = {
productList: PropTypes.object.isRequired
};
export default ProductList;
| sunitJindal/react-tutorial | redux-with-react/app/components/ProductList/presentational/ProductList.js | JavaScript | mit | 368 | [
30522,
12324,
10509,
1010,
1063,
17678,
13874,
2015,
1065,
2013,
1005,
10509,
1005,
1025,
9530,
3367,
4031,
9863,
1027,
1006,
24387,
1007,
1027,
1028,
1063,
9530,
3367,
20228,
1027,
24387,
1012,
4031,
9863,
1025,
9530,
3367,
3688,
1027,
487... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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... |
<html dir="LTR">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=Windows-1252" />
<meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5" />
<title>OptionConverter Class</title>
<xml>
</xml>
<link rel="stylesheet" type="text/css" href="MSDN.css" />
</head>
<body id="bodyID" class="dtBODY">
<div id="nsbanner">
<div id="bannerrow1">
<table class="bannerparthead" cellspacing="0">
<tr id="hdr">
<td class="runninghead">log4net SDK Documentation - Microsoft .NET Framework 4.0</td>
<td class="product">
</td>
</tr>
</table>
</div>
<div id="TitleRow">
<h1 class="dtH1">OptionConverter Class</h1>
</div>
</div>
<div id="nstext">
<p> A convenience class to convert property values to specific types. </p>
<p>For a list of all members of this type, see <a href="log4net.Util.OptionConverterMembers.html">OptionConverter Members</a>.</p>
<p>
<a href="ms-help://MS.NETFrameworkSDKv1.1/cpref/html/frlrfSystemObjectClassTopic.htm">System.Object</a>
<br /> <b>log4net.Util.OptionConverter</b></p>
<div class="syntax">
<span class="lang">[Visual Basic]</span>
<br />NotInheritable Public Class OptionConverter</div>
<div class="syntax">
<span class="lang">[C#]</span>
<div>public sealed class OptionConverter</div>
</div>
<H4 class="dtH4">Thread Safety</H4>
<P>Public static (<b>Shared</b> in Visual Basic) members of this type are
safe for multithreaded operations. Instance members are <b>not</b> guaranteed to be
thread-safe.</P>
<h4 class="dtH4">Remarks</h4>
<p> Utility functions for converting types and parsing values. </p>
<h4 class="dtH4">Requirements</h4><p><b>Namespace: </b><a href="log4net.Util.html">log4net.Util</a></p><p><b>Assembly: </b>log4net (in log4net.dll)
</p><h4 class="dtH4">See Also</h4><p><a href="log4net.Util.OptionConverterMembers.html">OptionConverter Members</a> | <a href="log4net.Util.html">log4net.Util Namespace</a></p><object type="application/x-oleobject" classid="clsid:1e2a7bd0-dab9-11d0-b93a-00c04fc99f9e" viewastext="true" style="display: none;"><param name="Keyword" value="OptionConverter class, about OptionConverter class"></param></object><hr /><div id="footer"><p><a href="http://logging.apache.org/log4net">Copyright 2004-2011 The Apache Software Foundation.</a></p><p></p></div></div>
</body>
</html> | npruehs/slash-framework | Ext/log4net-1.2.11/doc/release/sdk/log4net.Util.OptionConverter.html | HTML | mit | 2,577 | [
30522,
1026,
16129,
16101,
1027,
1000,
8318,
2099,
1000,
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,
3645,
1011,
8732... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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) 2006 Paolo Capriotti <p.capriotti@gmail.com>
(c) 2006 Maurizio Monge <maurizio.monge@kdemail.net>
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.
*/
#include <cmath>
#include <QDebug>
#include <QString>
#include "common.h"
#include "point.h"
Point::Point(int x, int y)
: x(x), y(y) {
}
Point::Point(const QPoint& p)
: x(p.x()), y(p.y()) {
}
Point::Point() {
}
Point::Point(const QString& str, int ysize) {
x = y = -1;
int length = str.length();
if(length == 0)
return;
if(str[0].isLetter()) {
char c = str[0].toAscii();
if(c >= 'a' && c <= 'z')
x = c-'a';
else if(c >= 'A' && c <= 'Z')
x = c-'A';
if(length>1)
y = ysize - str.mid(1).toInt();
}
else
y = ysize - str.toInt();
}
QString Point::row(int ysize) const {
if (y != -1)
return QString::number(ysize - y);
else
return QString();
}
QString Point::numcol(int xsize) const {
if (x != -1)
return QString::number(xsize - x);
else
return QString();
}
QString Point::col() const {
if (x != -1) {
if(x >= 26)
return QChar(static_cast<char>(x - 26 + 'A'));
else
return QChar(static_cast<char>(x + 'a'));
}
else
return QString();
}
QString Point::alpharow() const {
if (y != -1) {
if(y >= 26)
return QChar(static_cast<char>(y - 26 + 'A'));
else
return QChar(static_cast<char>(y + 'a'));
}
else
return QString();
}
QString Point::toString(int ysize) const {
return col() + row(ysize);
}
Point Point::operator+(const Point& other) const {
return Point(x + other.x, y + other.y);
}
Point Point::operator+=(const Point& other) {
return *this = *this + other;
}
Point Point::operator-() const {
return Point(-x, -y);
}
Point Point::operator-(const Point& other) const {
return Point(x - other.x, y - other.y);
}
Point Point::operator*(int n) const {
return Point(x * n, y * n);
}
Point Point::operator/(int n) const {
return Point(x / n, y / n);
}
Point Point::div(int n) const {
return Point(x >= 0 ? x / n : x / n - 1,
y >= 0 ? y / n : y / n - 1);
}
bool Point::operator==(const Point& other) const {
return x == other.x && y == other.y;
}
bool Point::operator!=(const Point& other) const {
return !(*this == other);
}
bool Point::operator<(const Point& other) const {
return y < other.y || (y == other.y && x < other.x);
}
bool Point::operator<=(const Point& other) const {
return y <= other.y || (y == other.y && x <= other.x);
}
bool Point::resembles(const Point& other) const {
return (other.x == -1 || x == other.x) &&
(other.y == -1 || y == other.y);
}
Point::operator QPoint() const {
return QPoint(x,y);
}
Point Point::normalizeInfinity() const {
return Point(
normalizeInfinityHelper(x),
normalizeInfinityHelper(y)
);
}
double Point::norm() const {
return sqrt((double)(x*x + y*y));
}
int Point::normalizeInfinityHelper(int n) const {
if (n == 0)
return 0;
else
return n > 0 ? 1 : -1;
}
QDebug operator<<(QDebug dbg, const Point& p) {
dbg << "(" << (p.x == -1 ? QString("?") : QString::number(p.x))
<< ", " << (p.y == -1 ? QString("?") : QString::number(p.y)) << ")";
return dbg;
}
| ruphy/tagua | src/point.cpp | C++ | gpl-2.0 | 3,545 | [
30522,
1013,
1008,
9385,
1006,
1039,
1007,
2294,
14174,
6178,
9488,
6916,
1026,
1052,
1012,
6178,
9488,
6916,
1030,
20917,
4014,
1012,
4012,
1028,
1006,
1039,
1007,
2294,
5003,
9496,
12426,
12256,
3351,
1026,
5003,
9496,
12426,
1012,
12256,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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 .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System.Collections.Generic;
using System.Collections.Immutable;
namespace Microsoft.CodeAnalysis.Shared.Collections
{
internal class SimpleIntervalTree<T, TIntrospector> : IntervalTree<T>
where TIntrospector : struct, IIntervalIntrospector<T>
{
private readonly TIntrospector _introspector;
public SimpleIntervalTree(in TIntrospector introspector, IEnumerable<T>? values)
{
_introspector = introspector;
if (values != null)
{
foreach (var value in values)
{
root = Insert(root, new Node(value), introspector);
}
}
}
protected ref readonly TIntrospector Introspector => ref _introspector;
/// <summary>
/// Warning. Mutates the tree in place.
/// </summary>
/// <param name="value"></param>
public void AddIntervalInPlace(T value)
{
var newNode = new Node(value);
this.root = Insert(root, newNode, in Introspector);
}
/// <summary>
/// Warning. Mutates the tree in place.
/// </summary>
public void ClearInPlace()
=> this.root = null;
public ImmutableArray<T> GetIntervalsThatOverlapWith(int start, int length)
=> GetIntervalsThatOverlapWith(start, length, in _introspector);
public ImmutableArray<T> GetIntervalsThatIntersectWith(int start, int length)
=> GetIntervalsThatIntersectWith(start, length, in _introspector);
public ImmutableArray<T> GetIntervalsThatContain(int start, int length)
=> GetIntervalsThatContain(start, length, in _introspector);
public void FillWithIntervalsThatOverlapWith(int start, int length, ref TemporaryArray<T> builder)
=> FillWithIntervalsThatOverlapWith(start, length, ref builder, in _introspector);
public void FillWithIntervalsThatIntersectWith(int start, int length, ref TemporaryArray<T> builder)
=> FillWithIntervalsThatIntersectWith(start, length, ref builder, in _introspector);
public void FillWithIntervalsThatContain(int start, int length, ref TemporaryArray<T> builder)
=> FillWithIntervalsThatContain(start, length, ref builder, in _introspector);
public bool HasIntervalThatIntersectsWith(int position)
=> HasIntervalThatIntersectsWith(position, in _introspector);
public bool HasIntervalThatOverlapsWith(int start, int length)
=> HasIntervalThatOverlapsWith(start, length, in _introspector);
public bool HasIntervalThatIntersectsWith(int start, int length)
=> HasIntervalThatIntersectsWith(start, length, in _introspector);
public bool HasIntervalThatContains(int start, int length)
=> HasIntervalThatContains(start, length, in _introspector);
protected int MaxEndValue(Node node)
=> GetEnd(node.MaxEndNode.Value, in _introspector);
}
}
| CyrusNajmabadi/roslyn | src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Collections/SimpleIntervalTree`2.cs | C# | mit | 3,238 | [
30522,
1013,
1013,
7000,
2000,
1996,
1012,
5658,
3192,
2104,
2028,
2030,
2062,
10540,
1012,
1013,
1013,
1996,
1012,
5658,
3192,
15943,
2023,
5371,
2000,
2017,
2104,
1996,
10210,
6105,
1012,
1013,
1013,
2156,
1996,
6105,
5371,
1999,
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... |
/* -*- Mode: C++; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* 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/. */
/* This program reads an ELF file and computes information about
* redundancies.
*/
#include <algorithm>
#include <fstream>
#include <string>
#include <vector>
#include <map>
#include <elf.h>
#include <sys/mman.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include <errno.h>
#include <getopt.h>
//----------------------------------------------------------------------
char* opt_type = "func";
char* opt_section = ".text";
//----------------------------------------------------------------------
static void
hexdump(ostream& out, const char* bytes, size_t count)
{
hex(out);
size_t off = 0;
while (off < count) {
out.form("%08lx: ", off);
const char* p = bytes + off;
int j = 0;
while (j < 16) {
out.form("%02x", p[j++] & 0xff);
if (j + off >= count)
break;
out.form("%02x ", p[j++] & 0xff);
if (j + off >= count)
break;
}
// Pad
for (; j < 16; ++j)
out << ((j%2) ? " " : " ");
for (j = 0; j < 16; ++j) {
if (j + off < count)
out.put(isprint(p[j]) ? p[j] : '.');
}
out << endl;
off += 16;
}
}
//----------------------------------------------------------------------
int
verify_elf_header(const Elf32_Ehdr* hdr)
{
if (hdr->e_ident[EI_MAG0] != ELFMAG0
|| hdr->e_ident[EI_MAG1] != ELFMAG1
|| hdr->e_ident[EI_MAG2] != ELFMAG2
|| hdr->e_ident[EI_MAG3] != ELFMAG3) {
cerr << "not an elf file" << endl;
return -1;
}
if (hdr->e_ident[EI_CLASS] != ELFCLASS32) {
cerr << "not a 32-bit elf file" << endl;
return -1;
}
if (hdr->e_ident[EI_DATA] != ELFDATA2LSB) {
cerr << "not a little endian elf file" << endl;
return -1;
}
if (hdr->e_ident[EI_VERSION] != EV_CURRENT) {
cerr << "incompatible version" << endl;
return -1;
}
return 0;
}
//----------------------------------------------------------------------
class elf_symbol : public Elf32_Sym
{
public:
elf_symbol(const Elf32_Sym& sym)
{ ::memcpy(static_cast<Elf32_Sym*>(this), &sym, sizeof(Elf32_Sym)); }
friend bool operator==(const elf_symbol& lhs, const elf_symbol& rhs) {
return 0 == ::memcmp(static_cast<const Elf32_Sym*>(&lhs),
static_cast<const Elf32_Sym*>(&rhs),
sizeof(Elf32_Sym)); }
};
//----------------------------------------------------------------------
static const char*
st_bind(unsigned char info)
{
switch (ELF32_ST_BIND(info)) {
case STB_LOCAL: return "local";
case STB_GLOBAL: return "global";
case STB_WEAK: return "weak";
default: return "unknown";
}
}
static const char*
st_type(unsigned char info)
{
switch (ELF32_ST_TYPE(info)) {
case STT_NOTYPE: return "none";
case STT_OBJECT: return "object";
case STT_FUNC: return "func";
case STT_SECTION: return "section";
case STT_FILE: return "file";
default: return "unknown";
}
}
static unsigned char
st_type(const char* type)
{
if (strcmp(type, "none") == 0) {
return STT_NOTYPE;
}
else if (strcmp(type, "object") == 0) {
return STT_OBJECT;
}
else if (strcmp(type, "func") == 0) {
return STT_FUNC;
}
else {
return 0;
}
}
//----------------------------------------------------------------------
typedef vector<elf_symbol> elf_symbol_table;
typedef map< basic_string<char>, elf_symbol_table > elf_text_map;
void
process_mapping(char* mapping, size_t size)
{
const Elf32_Ehdr* ehdr = reinterpret_cast<Elf32_Ehdr*>(mapping);
if (verify_elf_header(ehdr) < 0)
return;
// find the section headers
const Elf32_Shdr* shdrs = reinterpret_cast<Elf32_Shdr*>(mapping + ehdr->e_shoff);
// find the section header string table, .shstrtab
const Elf32_Shdr* shstrtabsh = shdrs + ehdr->e_shstrndx;
const char* shstrtab = mapping + shstrtabsh->sh_offset;
// find the sections we care about
const Elf32_Shdr *symtabsh, *strtabsh, *textsh;
int textndx;
for (int i = 0; i < ehdr->e_shnum; ++i) {
basic_string<char> name(shstrtab + shdrs[i].sh_name);
if (name == opt_section) {
textsh = shdrs + i;
textndx = i;
}
else if (name == ".symtab") {
symtabsh = shdrs + i;
}
else if (name == ".strtab") {
strtabsh = shdrs + i;
}
}
// find the .strtab
char* strtab = mapping + strtabsh->sh_offset;
// find the .text
char* text = mapping + textsh->sh_offset;
int textaddr = textsh->sh_addr;
// find the symbol table
int nentries = symtabsh->sh_size / sizeof(Elf32_Sym);
Elf32_Sym* symtab = reinterpret_cast<Elf32_Sym*>(mapping + symtabsh->sh_offset);
// look for symbols in the .text section
elf_text_map textmap;
for (int i = 0; i < nentries; ++i) {
const Elf32_Sym* sym = symtab + i;
if (sym->st_shndx == textndx &&
ELF32_ST_TYPE(sym->st_info) == st_type(opt_type) &&
sym->st_size) {
basic_string<char> functext(text + sym->st_value - textaddr, sym->st_size);
elf_symbol_table& syms = textmap[functext];
if (syms.end() == find(syms.begin(), syms.end(), elf_symbol(*sym)))
syms.insert(syms.end(), *sym);
}
}
int uniquebytes = 0, totalbytes = 0;
int uniquecount = 0, totalcount = 0;
for (elf_text_map::const_iterator entry = textmap.begin();
entry != textmap.end();
++entry) {
const elf_symbol_table& syms = entry->second;
if (syms.size() <= 1)
continue;
int sz = syms.begin()->st_size;
uniquebytes += sz;
totalbytes += sz * syms.size();
uniquecount += 1;
totalcount += syms.size();
for (elf_symbol_table::const_iterator sym = syms.begin(); sym != syms.end(); ++sym)
cout << strtab + sym->st_name << endl;
dec(cout);
cout << syms.size() << " copies of " << sz << " bytes";
cout << " (" << ((syms.size() - 1) * sz) << " redundant bytes)" << endl;
hexdump(cout, entry->first.data(), entry->first.size());
cout << endl;
}
dec(cout);
cout << "bytes unique=" << uniquebytes << ", total=" << totalbytes << endl;
cout << "entries unique=" << uniquecount << ", total=" << totalcount << endl;
}
void
process_file(const char* name)
{
int fd = open(name, O_RDWR);
if (fd >= 0) {
struct stat statbuf;
if (fstat(fd, &statbuf) >= 0) {
size_t size = statbuf.st_size;
void* mapping = mmap(0, size, PROT_READ, MAP_SHARED, fd, 0);
if (mapping != MAP_FAILED) {
process_mapping(static_cast<char*>(mapping), size);
munmap(mapping, size);
}
}
close(fd);
}
}
static void
usage()
{
cerr << "foldelf [--section=<section>] [--type=<type>] [file ...]\n\
--section, -s the section of the ELF file to scan; defaults\n\
to ``.text''. Valid values include any section\n\
of the ELF file.\n\
--type, -t the type of object to examine in the section;\n\
defaults to ``func''. Valid values include\n\
``none'', ``func'', or ``object''.\n";
}
static struct option opts[] = {
{ "type", required_argument, 0, 't' },
{ "section", required_argument, 0, 's' },
{ "help", no_argument, 0, '?' },
{ 0, 0, 0, 0 }
};
int
main(int argc, char* argv[])
{
while (1) {
int option_index = 0;
int c = getopt_long(argc, argv, "t:s:", opts, &option_index);
if (c < 0) break;
switch (c) {
case 't':
opt_type = optarg;
break;
case 's':
opt_section = optarg;
break;
case '?':
usage();
break;
}
}
for (int i = optind; i < argc; ++i)
process_file(argv[i]);
return 0;
}
| sergecodd/FireFox-OS | B2G/gecko/tools/footprint/foldelf.cpp | C++ | apache-2.0 | 8,544 | [
30522,
1013,
1008,
1011,
1008,
1011,
5549,
1024,
1039,
1009,
1009,
1025,
27427,
4765,
1011,
21628,
2015,
1011,
5549,
1024,
9152,
2140,
1025,
1039,
1011,
3937,
1011,
16396,
1024,
1018,
1011,
1008,
1011,
1008,
1008,
2023,
3120,
3642,
2433,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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) Rich Hickey. All rights reserved.
* The use and distribution terms for this software are covered by the
* Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)
* which can be found in the file epl-v10.html at the root of this distribution.
* By using this software in any fashion, you are agreeing to be bound by
* the terms of this license.
* You must not remove this notice, or any other, from this software.
**/
/* rich Mar 3, 2008 */
package clojure.lang;
import java.io.IOException;
import java.io.NotSerializableException;
import java.util.Enumeration;
public class EnumerationSeq extends ASeq{
final Enumeration iter;
final State state;
static class State{
volatile Object val;
volatile Object _rest;
}
public static EnumerationSeq create(Enumeration iter){
if(iter.hasMoreElements())
return new EnumerationSeq(iter);
return null;
}
EnumerationSeq(Enumeration iter){
this.iter = iter;
state = new State();
this.state.val = state;
this.state._rest = state;
}
EnumerationSeq(IPersistentMap meta, Enumeration iter, State state){
super(meta);
this.iter = iter;
this.state = state;
}
public Object first(){
if(state.val == state)
synchronized(state)
{
if(state.val == state)
state.val = iter.nextElement();
}
return state.val;
}
public ISeq next(){
if(state._rest == state)
synchronized(state)
{
if(state._rest == state)
{
first();
state._rest = create(iter);
}
}
return (ISeq) state._rest;
}
public EnumerationSeq withMeta(IPersistentMap meta){
return new EnumerationSeq(meta, iter, state);
}
private void writeObject (java.io.ObjectOutputStream out) throws IOException {
throw new NotSerializableException(getClass().getName());
}
}
| zephyrplugins/zephyr | zephyr.plugin.clojure/clojure-1.2.0/src/jvm/clojure/lang/EnumerationSeq.java | Java | epl-1.0 | 1,782 | [
30522,
1013,
1008,
1008,
1008,
9385,
1006,
1039,
1007,
4138,
7632,
29183,
1012,
2035,
2916,
9235,
1012,
1008,
1996,
2224,
1998,
4353,
3408,
2005,
2023,
4007,
2024,
3139,
2011,
1996,
1008,
13232,
2270,
6105,
1015,
1012,
1014,
1006,
8299,
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... |
package no.ntnu.assignmentsystem.services;
import java.util.List;
import java.util.Optional;
import no.ntnu.assignmentsystem.model.Assignment;
import no.ntnu.assignmentsystem.model.Course;
import no.ntnu.assignmentsystem.model.ModelLoader;
import no.ntnu.assignmentsystem.model.Participant;
import no.ntnu.assignmentsystem.model.Problem;
import no.ntnu.assignmentsystem.model.SourceCodeFile;
import no.ntnu.assignmentsystem.model.User;
import org.eclipse.emf.ecore.EObject;
public class ModelServices {
private final ModelLoader modelLoader;
public ModelServices(ModelLoader modelLoader) {
this.modelLoader = modelLoader;
}
public Optional<? extends SourceCodeFile> getSourceCodeFile(String fileId) {
return Optional.ofNullable((SourceCodeFile)findObject(fileId));
}
public Optional<? extends Problem> getProblem(String problemId) {
return Optional.ofNullable((Problem)findObject(problemId));
}
public Optional<Assignment> getAssignment(String assignmentId) {
return Optional.ofNullable((Assignment)findObject(assignmentId));
}
public Optional<Course> getCourse(String courseId) {
return Optional.ofNullable((Course)findObject(courseId));
}
public Optional<? extends Participant> getParticipant(String courseId, String userId) {
return getCourse(courseId).flatMap(
course -> course.getParticipants().stream().filter(
participant -> getUser(userId).equals(Optional.ofNullable(participant.getUser()))
).findAny()
);
}
public Optional<User> getUser(String userId) {
return Optional.ofNullable((User)findObject(userId));
}
public List<User> getUsers() {
return modelLoader.getUoD().getUsers();
}
// --- Private methods ---
private EObject findObject(String id) {
return modelLoader.findObject(id);
}
}
| chrrasmussen/NTNU-Master-Project | no.ntnu.assignmentsystem.model/src/no/ntnu/assignmentsystem/services/ModelServices.java | Java | mit | 1,773 | [
30522,
7427,
2053,
1012,
23961,
11231,
1012,
14799,
27268,
6633,
1012,
2578,
1025,
12324,
9262,
1012,
21183,
4014,
1012,
2862,
1025,
12324,
9262,
1012,
21183,
4014,
1012,
11887,
1025,
12324,
2053,
1012,
23961,
11231,
1012,
14799,
27268,
6633,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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... |
//========================================================================
// GLFW 3.3 OSMesa - www.glfw.org
//------------------------------------------------------------------------
// Copyright (c) 2016 Google Inc.
// Copyright (c) 2006-2016 Camilla Löwy <elmindreda@glfw.org>
//
// This software is provided 'as-is', without any express or implied
// warranty. In no event will the authors be held liable for any damages
// arising from the use of this software.
//
// Permission is granted to anyone to use this software for any purpose,
// including commercial applications, and to alter it and redistribute it
// freely, subject to the following restrictions:
//
// 1. The origin of this software must not be misrepresented; you must not
// claim that you wrote the original software. If you use this software
// in a product, an acknowledgment in the product documentation would
// be appreciated but is not required.
//
// 2. Altered source versions must be plainly marked as such, and must not
// be misrepresented as being the original software.
//
// 3. This notice may not be removed or altered from any source
// distribution.
//
//========================================================================
#define OSMESA_RGBA 0x1908
#define OSMESA_FORMAT 0x22
#define OSMESA_DEPTH_BITS 0x30
#define OSMESA_STENCIL_BITS 0x31
#define OSMESA_ACCUM_BITS 0x32
#define OSMESA_PROFILE 0x33
#define OSMESA_CORE_PROFILE 0x34
#define OSMESA_COMPAT_PROFILE 0x35
#define OSMESA_CONTEXT_MAJOR_VERSION 0x36
#define OSMESA_CONTEXT_MINOR_VERSION 0x37
typedef void* OSMesaContext;
typedef void (*OSMESAproc)(void);
typedef OSMesaContext (GLAPIENTRY * PFN_OSMesaCreateContextExt)(GLenum,GLint,GLint,GLint,OSMesaContext);
typedef OSMesaContext (GLAPIENTRY * PFN_OSMesaCreateContextAttribs)(const int*,OSMesaContext);
typedef void (GLAPIENTRY * PFN_OSMesaDestroyContext)(OSMesaContext);
typedef int (GLAPIENTRY * PFN_OSMesaMakeCurrent)(OSMesaContext,void*,int,int,int);
typedef int (GLAPIENTRY * PFN_OSMesaGetColorBuffer)(OSMesaContext,int*,int*,int*,void**);
typedef int (GLAPIENTRY * PFN_OSMesaGetDepthBuffer)(OSMesaContext,int*,int*,int*,void**);
typedef GLFWglproc (GLAPIENTRY * PFN_OSMesaGetProcAddress)(const char*);
#define OSMesaCreateContextExt _glfw.osmesa.CreateContextExt
#define OSMesaCreateContextAttribs _glfw.osmesa.CreateContextAttribs
#define OSMesaDestroyContext _glfw.osmesa.DestroyContext
#define OSMesaMakeCurrent _glfw.osmesa.MakeCurrent
#define OSMesaGetColorBuffer _glfw.osmesa.GetColorBuffer
#define OSMesaGetDepthBuffer _glfw.osmesa.GetDepthBuffer
#define OSMesaGetProcAddress _glfw.osmesa.GetProcAddress
#define _GLFW_OSMESA_CONTEXT_STATE _GLFWcontextOSMesa osmesa
#define _GLFW_OSMESA_LIBRARY_CONTEXT_STATE _GLFWlibraryOSMesa osmesa
// OSMesa-specific per-context data
//
typedef struct _GLFWcontextOSMesa
{
OSMesaContext handle;
int width;
int height;
void* buffer;
} _GLFWcontextOSMesa;
// OSMesa-specific global data
//
typedef struct _GLFWlibraryOSMesa
{
void* handle;
PFN_OSMesaCreateContextExt CreateContextExt;
PFN_OSMesaCreateContextAttribs CreateContextAttribs;
PFN_OSMesaDestroyContext DestroyContext;
PFN_OSMesaMakeCurrent MakeCurrent;
PFN_OSMesaGetColorBuffer GetColorBuffer;
PFN_OSMesaGetDepthBuffer GetDepthBuffer;
PFN_OSMesaGetProcAddress GetProcAddress;
} _GLFWlibraryOSMesa;
GLFWbool _glfwInitOSMesa(void);
void _glfwTerminateOSMesa(void);
GLFWbool _glfwCreateContextOSMesa(_GLFWwindow* window,
const _GLFWctxconfig* ctxconfig,
const _GLFWfbconfig* fbconfig);
| endlessm/chromium-browser | third_party/glfw/src/src/osmesa_context.h | C | bsd-3-clause | 3,768 | [
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... |
# -*- encoding : utf-8 -*-
module DateTimeHelper
# Public: Usually-correct format for a DateTime-ish object
# To define a new new format define the `simple_date_{FORMAT}` method
#
# date - a DateTime, Date or Time
# opts - a Hash of options (default: { format: :html})
# :format - :html returns a HTML <time> tag
# :text returns a plain String
#
# Examples
#
# simple_date(Time.now)
# # => "<time>..."
#
# simple_date(Time.now, :format => :text)
# # => "March 10, 2014"
#
# Returns a String
# Raises ArgumentError if the format is unrecognized
def simple_date(date, opts = {})
opts = { :format => :html }.merge(opts)
date_formatter = "simple_date_#{ opts[:format] }"
if respond_to?(date_formatter)
send(date_formatter, date)
else
raise ArgumentError, "Unrecognized format :#{ opts[:format] }"
end
end
# Usually-correct HTML formatting of a DateTime-ish object
# Use LinkToHelper#simple_date with desired formatting options
#
# date - a DateTime, Date or Time
#
# Returns a String
def simple_date_html(date)
date = date.in_time_zone unless date.is_a?(Date)
time_tag date, simple_date_text(date), :title => date.to_s
end
# Usually-correct plain text formatting of a DateTime-ish object
# Use LinkToHelper#simple_date with desired formatting options
#
# date - a DateTime, Date or Time
#
# Returns a String
def simple_date_text(date)
date = date.in_time_zone.to_date unless date.is_a? Date
date_format = _('simple_date_format')
date_format = :long if date_format == 'simple_date_format'
I18n.l(date, :format => date_format)
end
# Strips the date from a DateTime
#
# date - a DateTime, Date or Time
#
# Examples
#
# simple_time(Time.now)
# # => "10:46:54"
#
# Returns a String
def simple_time(date)
date.strftime("%H:%M:%S").strip
end
end
| andreicristianpetcu/alaveteli_old | app/helpers/date_time_helper.rb | Ruby | agpl-3.0 | 1,932 | [
30522,
1001,
1011,
1008,
1011,
17181,
1024,
21183,
2546,
1011,
1022,
1011,
1008,
1011,
11336,
3058,
7292,
16001,
4842,
1001,
2270,
1024,
2788,
1011,
6149,
4289,
2005,
1037,
3058,
7292,
1011,
2003,
2232,
4874,
1001,
2000,
9375,
1037,
2047,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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... |
CREATE TABLE [dbo].[ExceptionsByCategory] (
[CategoryId] BIGINT NOT NULL,
[ExceptionLogId] BIGINT NOT NULL,
FOREIGN KEY ([CategoryId]) REFERENCES [dbo].[Categories] ([Id]),
FOREIGN KEY ([ExceptionLogId]) REFERENCES [dbo].[ExceptionLogs] ([Id])
);
| gcvalderrama/heimdall | Heimdall_web/HeimdallDB/dbo/Tables/ExceptionsByCategory.sql | SQL | apache-2.0 | 278 | [
30522,
3443,
2795,
1031,
16962,
2080,
1033,
1012,
1031,
11790,
3762,
16280,
20255,
2100,
1033,
1006,
1031,
4696,
3593,
1033,
2502,
18447,
2025,
19701,
1010,
1031,
6453,
21197,
3593,
1033,
2502,
18447,
2025,
19701,
1010,
3097,
3145,
1006,
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... |
/*
* linux/drivers/mtd/nand/ox810_nand.c
*
* Copyright (C) 2008 Oxford Semiconductor
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
* Overview:
* This is a device driver for the NAND flash device found on the
* OX810 demo board.
*/
#include <linux/kernel.h>
#include <linux/device.h>
#include <linux/delay.h>
#include <linux/mtd/mtd.h>
#include <linux/mtd/nand.h>
#include <linux/mtd/partitions.h>
#include <asm/io.h>
#include <asm/arch-oxnas/hardware.h>
#define OX810_NAND_NAME "OX810_NAND";
#define OX810_NAND_BASE STATIC_CS1_BASE // base address of NAND chip on static bus
#define OX810_NAND_DATA OX810_NAND_BASE + 0x0000
//#define OX810_NAND_ADDRESS_LATCH OX810_NAND_BASE + 0x1000
#define OX810_NAND_ADDRESS_LATCH OX810_NAND_BASE + 0x8000
//#define OX810_NAND_COMMAND_LATCH OX810_NAND_BASE + 0x2000
#define OX810_NAND_COMMAND_LATCH OX810_NAND_BASE + 0x4000
// commands
#define OX810_NAND_COMMAND_READ_CYCLE1 0x00
#define OX810_NAND_COMMAND_WRITE_CYCLE2 0x10
#define OX810_NAND_COMMAND_READ_CYCLE2 0x30
#define OX810_NAND_COMMAND_CACHE_READ 0x31
#define OX810_NAND_COMMAND_BLOCK_ERASE 0x60
#define OX810_NAND_COMMAND_READ_STATUS 0x70
#define OX810_NAND_COMMAND_READ_ID 0x90
#define OX810_NAND_COMMAND_STATUS 0x70
#define OX810_NAND_COMMAND_WRITE_CYCLE1 0x80
#define OX810_NAND_COMMAND_ERASE_CONFIRM 0xd0
#define OX810_NAND_COMMAND_PARAMETER_PAGE 0xec
#define OX810_NAND_COMMAND_RESET 0xff
// status register bits
#define OX810_NAND_STATUS_FAIL (1 << 0)
#define OX810_NAND_STATUS_READY (1 << 6)
#ifdef CONFIG_MTD_PARTITIONS
#define NUM_PARTITIONS 2
static struct mtd_partition partition_info[] =
{
{
.name = "Boot partition",
.offset = 0,
.size = 1024 * 1024 * 64
},
{
.name = "Data Partition",
.offset = MTDPART_OFS_NXTBLK,
.size = MTDPART_SIZ_FULL
}
};
#endif
static struct priv {
struct mtd_info *mtd;
} priv;
static void ox810_nand_write_command(u_int8_t command)
{
writeb(command, OX810_NAND_COMMAND_LATCH);
}
static u_int8_t ox810_nand_read_data(void)
{
return readb(OX810_NAND_DATA);
}
static uint8_t ox810_nand_wait_for_ready(void)
{
int timeout = 100;
uint8_t status;
ox810_nand_write_command(OX810_NAND_COMMAND_STATUS);
status = ox810_nand_read_data();
if (status & OX810_NAND_STATUS_READY)
return status;
udelay(100);
while (timeout--) {
status = ox810_nand_read_data();
if (status & OX810_NAND_STATUS_READY)
return status;
msleep(1);
}
printk(KERN_ERR "OX810 NAND Timeout waiting for ready\n");
return OX810_NAND_STATUS_FAIL;
}
static void ox810_nand_hwcontrol(struct mtd_info *mtd, int cmd, unsigned int ctrl)
{
struct nand_chip *this = (struct nand_chip *)priv.mtd->priv;
unsigned long bits = 0;
char *addr = this->IO_ADDR_W;
if (ctrl & NAND_CLE)
bits |= (OX810_NAND_COMMAND_LATCH - OX810_NAND_BASE);
if (ctrl & NAND_ALE)
bits |= (OX810_NAND_ADDRESS_LATCH - OX810_NAND_BASE);
if (cmd != NAND_CMD_NONE)
writeb(cmd, addr + bits);
}
static int ox810_nand_init(void)
{
int err,i ;
struct nand_chip *this;
priv.mtd = kzalloc(sizeof(struct mtd_info) + sizeof(struct nand_chip), GFP_KERNEL);
if (!priv.mtd)
return -ENOMEM;
this = (struct nand_chip *)((char *)(priv.mtd) + sizeof(struct mtd_info));
priv.mtd->priv = this;
priv.mtd->owner = THIS_MODULE;
this->IO_ADDR_R = (void __iomem *)OX810_NAND_DATA;
this->IO_ADDR_W = (void __iomem *)OX810_NAND_DATA;
this->cmd_ctrl = ox810_nand_hwcontrol;
this->dev_ready = NULL;
this->ecc.mode = NAND_ECC_SOFT;
// enable CS_1
*(volatile u32*)SYS_CTRL_GPIO_PRIMSEL_CTRL_0 |= 0x00100000;
*(volatile u32*)SYS_CTRL_GPIO_SECSEL_CTRL_0 &= ~0x00100000;
*(volatile u32*)SYS_CTRL_GPIO_TERTSEL_CTRL_0 &= ~0x00100000;
// reset
ox810_nand_write_command(OX810_NAND_COMMAND_RESET);
ox810_nand_wait_for_ready();
ox810_nand_write_command(OX810_NAND_COMMAND_PARAMETER_PAGE);
ox810_nand_wait_for_ready();
ox810_nand_write_command(OX810_NAND_COMMAND_READ_CYCLE1);
for (i = 0; i < 137; i++) { // skip to max page read time parameter
ox810_nand_read_data();
}
this->chip_delay = (ox810_nand_read_data() + 256 * ox810_nand_read_data()) / 1000;
#ifdef CONFIG_MTD_DEBUG
printk("Page read time %dms\n", this->chip_delay);
#endif
if (nand_scan(priv.mtd, 1)) {
err = -ENXIO;
goto error;
}
err = add_mtd_device(priv.mtd);
if (err) {
err = -ENFILE;
goto error;
}
#ifdef CONFIG_MTD_PARTITIONS
add_mtd_partitions(priv.mtd, partition_info, NUM_PARTITIONS);
#endif
return 0;
error:
kfree(priv.mtd);
return err;
}
static void ox810_nand_exit(void)
{
if (priv.mtd) {
del_mtd_device(priv.mtd);
nand_release(priv.mtd);
kfree(priv.mtd);
}
}
module_init(ox810_nand_init);
module_exit(ox810_nand_exit);
MODULE_LICENSE("GPL");
MODULE_AUTHOR("Oxford Semiconductor");
MODULE_DESCRIPTION("NAND flash driver 810 demo board");
| choushane/MaRa-a1a0a5aNaL | target/linux/ox810/files/drivers/mtd/nand/ox810_nand.c | C | gpl-2.0 | 4,951 | [
30522,
1013,
1008,
1008,
11603,
1013,
6853,
1013,
11047,
2094,
1013,
16660,
2094,
1013,
23060,
2620,
10790,
1035,
16660,
2094,
1012,
1039,
1008,
1008,
9385,
1006,
1039,
1007,
2263,
4345,
20681,
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... |
<?php
/* vim: set expandtab sw=4 ts=4 sts=4: */
/**
* Handles table zoom search tab
*
* display table zoom search form, create SQL queries from form data
*
*/
/**
* Gets some core libraries
*/
require_once './libraries/common.inc.php';
require_once './libraries/mysql_charsets.lib.php';
require_once './libraries/tbl_select.lib.php';
require_once './libraries/relation.lib.php';
require_once './libraries/tbl_info.inc.php';
$GLOBALS['js_include'][] = 'makegrid.js';
$GLOBALS['js_include'][] = 'sql.js';
$GLOBALS['js_include'][] = 'functions.js';
$GLOBALS['js_include'][] = 'date.js';
/* < IE 9 doesn't support canvas natively */
if (PMA_USR_BROWSER_AGENT == 'IE' && PMA_USR_BROWSER_VER < 9) {
$GLOBALS['js_include'][] = 'canvg/flashcanvas.js';
}
$GLOBALS['js_include'][] = 'jqplot/jquery.jqplot.js';
$GLOBALS['js_include'][] = 'jqplot/plugins/jqplot.canvasTextRenderer.js';
$GLOBALS['js_include'][] = 'jqplot/plugins/jqplot.canvasAxisLabelRenderer.js';
$GLOBALS['js_include'][] = 'jqplot/plugins/jqplot.dateAxisRenderer.js';
$GLOBALS['js_include'][] = 'jqplot/plugins/jqplot.highlighter.js';
$GLOBALS['js_include'][] = 'jqplot/plugins/jqplot.cursor.js';
$GLOBALS['js_include'][] = 'canvg/canvg.js';
$GLOBALS['js_include'][] = 'jquery/jquery-ui-1.8.16.custom.js';
$GLOBALS['js_include'][] = 'jquery/timepicker.js';
$GLOBALS['js_include'][] = 'tbl_zoom_plot_jqplot.js';
/**
* Handle AJAX request for data row on point select
* @var post_params Object containing parameters for the POST request
*/
if (isset($_REQUEST['get_data_row']) && $_REQUEST['get_data_row'] == true) {
$extra_data = array();
$row_info_query = 'SELECT * FROM `' . $_REQUEST['db'] . '`.`'
. $_REQUEST['table'] . '` WHERE ' . $_REQUEST['where_clause'];
$result = PMA_DBI_query($row_info_query . ";", null, PMA_DBI_QUERY_STORE);
$fields_meta = PMA_DBI_get_fields_meta($result);
while ($row = PMA_DBI_fetch_assoc($result)) {
// for bit fields we need to convert them to printable form
$i = 0;
foreach ($row as $col => $val) {
if ($fields_meta[$i]->type == 'bit') {
$row[$col] = PMA_printable_bit_value($val, $fields_meta[$i]->length);
}
$i++;
}
$extra_data['row_info'] = $row;
}
PMA_ajaxResponse(null, true, $extra_data);
}
$titles['Browse'] = PMA_getIcon('b_browse.png', __('Browse foreign values'));
/**
* Not selection yet required -> displays the selection form
*/
// Gets some core libraries
require_once './libraries/tbl_common.php';
$url_query .= '&goto=tbl_select.php&back=tbl_select.php';
/**
* Gets tables informations
*/
require_once './libraries/tbl_info.inc.php';
/**
* Displays top menu links
*/
require_once './libraries/tbl_links.inc.php';
if (! isset($goto)) {
$goto = $GLOBALS['cfg']['DefaultTabTable'];
}
// Defines the url to return to in case of error in the next sql statement
$err_url = $goto . '?' . PMA_generate_common_url($db, $table);
// Gets the list and number of fields
list($fields_list, $fields_type, $fields_collation, $fields_null) = PMA_tbl_getFields($db, $table);
$fields_cnt = count($fields_list);
// retrieve keys into foreign fields, if any
// check also foreigners even if relwork is FALSE (to get
// foreign keys from innodb)
$foreigners = PMA_getForeigners($db, $table);
$flag = 1;
$tbl_fields_type = $tbl_fields_collation = $tbl_fields_null = array();
if (! isset($zoom_submit) && ! isset($inputs)) {
$dataLabel = PMA_getDisplayField($db, $table);
}
?>
<div id="sqlqueryresults"></div>
<fieldset id="fieldset_subtab">
<?php
$url_params = array();
$url_params['db'] = $db;
$url_params['table'] = $table;
echo PMA_generate_html_tabs(PMA_tbl_getSubTabs(), $url_params, '', 'topmenu2');
/**
* Set the field name,type,collation and whether null on select of a coulmn
*/
if (isset($inputs) && ($inputs[0] != 'pma_null' || $inputs[1] != 'pma_null')) {
$flag = 2;
for ($i = 0 ; $i < 4 ; $i++) {
if ($inputs[$i] != 'pma_null') {
$key = array_search($inputs[$i], $fields_list);
$tbl_fields_type[$i] = $fields_type[$key];
$tbl_fields_collation[$i] = $fields_collation[$key];
$tbl_fields_null[$i] = $fields_null[$key];
}
}
}
/*
* Form for input criteria
*/
?>
<form method="post" action="tbl_zoom_select.php" name="insertForm" id="zoom_search_form"
<?php echo ($GLOBALS['cfg']['AjaxEnable'] ? ' class="ajax"' : ''); ?>>
<?php echo PMA_generate_common_hidden_inputs($db, $table); ?>
<input type="hidden" name="goto" value="<?php echo $goto; ?>" />
<input type="hidden" name="back" value="tbl_zoom_select.php" />
<input type="hidden" name="flag" id="id_flag" value="<?php echo $flag; ?>" />
<fieldset id="inputSection">
<legend><?php echo __('Do a "query by example" (wildcard: "%") for two different columns') ?></legend>
<table class="data">
<?php echo PMA_tbl_setTableHeader();?>
<tbody>
<?php
$odd_row = true;
for ($i = 0; $i < 4; $i++) {
if ($i == 2) {
echo "<tr><td>";
echo __("Additional search criteria");
echo "</td></tr>";
}
?>
<tr class="noclick <?php echo $odd_row ? 'odd' : 'even'; $odd_row = ! $odd_row; ?>">
<th><select name="inputs[]" id="<?php echo 'tableid_' . $i; ?>" >
<option value="<?php echo 'pma_null'; ?>"><?php echo __('None'); ?></option>
<?php
for ($j = 0 ; $j < $fields_cnt ; $j++) {
if (isset($inputs[$i]) && $inputs[$i] == htmlspecialchars($fields_list[$j])) {?>
<option value="<?php echo htmlspecialchars($fields_list[$j]);?>" selected="selected">
<?php echo htmlspecialchars($fields_list[$j]);?></option>
<?php
} else { ?>
<option value="<?php echo htmlspecialchars($fields_list[$j]);?>">
<?php echo htmlspecialchars($fields_list[$j]);?></option>
<?php
}
} ?>
</select></th>
<td><?php if (isset($tbl_fields_type[$i])) echo $tbl_fields_type[$i]; ?></td>
<td><?php if (isset($tbl_fields_collation[$i])) echo $tbl_fields_collation[$i]; ?></td>
<td>
<?php
if (isset($inputs) && $inputs[$i] != 'pma_null') { ?>
<select name="zoomFunc[]">
<?php
if (strncasecmp($tbl_fields_type[$i], 'enum', 4) == 0) {
foreach ($GLOBALS['cfg']['EnumOperators'] as $fc) {
if (isset($zoomFunc[$i]) && $zoomFunc[$i] == htmlspecialchars($fc)) {
echo "\n" . ' '
. '<option value="' . htmlspecialchars($fc) . '" selected="selected">'
. htmlspecialchars($fc) . '</option>';
} else {
echo "\n" . ' '
. '<option value="' . htmlspecialchars($fc) . '">'
. htmlspecialchars($fc) . '</option>';
}
}
} elseif (preg_match('@char|blob|text|set@i', $tbl_fields_type[$i])) {
foreach ($GLOBALS['cfg']['TextOperators'] as $fc) {
if (isset($zoomFunc[$i]) && $zoomFunc[$i] == $fc) {
echo "\n" . ' '
. '<option value="' . htmlspecialchars($fc) . '" selected="selected">'
. htmlspecialchars($fc) . '</option>';
} else {
echo "\n" . ' '
. '<option value="' . htmlspecialchars($fc) . '">'
. htmlspecialchars($fc) . '</option>';
}
}
} else {
foreach ($GLOBALS['cfg']['NumOperators'] as $fc) {
if (isset($zoomFunc[$i]) && $zoomFunc[$i] == $fc) {
echo "\n" . ' '
. '<option value="' . htmlspecialchars($fc) . '" selected="selected">'
. htmlspecialchars($fc) . '</option>';
} else {
echo "\n" . ' '
. '<option value="' . htmlspecialchars($fc) . '">'
. htmlspecialchars($fc) . '</option>';
}
}
} // end if... else...
if ($tbl_fields_null[$i]) {
foreach ($GLOBALS['cfg']['NullOperators'] as $fc) {
if (isset($zoomFunc[$i]) && $zoomFunc[$i] == $fc) {
echo "\n" . ' '
. '<option value="' . htmlspecialchars($fc) . '" selected="selected">'
. htmlspecialchars($fc) . '</option>';
} else {
echo "\n" . ' '
. '<option value="' . htmlspecialchars($fc) . '">'
. htmlspecialchars($fc) . '</option>';
}
}
}
?>
</select>
</td>
<td>
<?php
$field = $inputs[$i];
$foreignData = PMA_getForeignData($foreigners, $field, false, '', '');
if (isset($fields)) {
echo PMA_getForeignFields_Values(
$foreigners, $foreignData, $field, $tbl_fields_type, $i, $db,
$table, $titles, $GLOBALS['cfg']['ForeignKeyMaxLimit'], $fields
);
} else {
echo PMA_getForeignFields_Values(
$foreigners, $foreignData, $field, $tbl_fields_type, $i, $db,
$table, $titles, $GLOBALS['cfg']['ForeignKeyMaxLimit'], ''
);
}
} else { ?>
</td><td></td>
<?php
} ?>
</tr>
<tr><td>
<input type="hidden" name="types[<?php echo $i; ?>]" id="types_<?php echo $i; ?>"
value="<?php if(isset($tbl_fields_type[$i]))echo $tbl_fields_type[$i]; ?>" />
<input type="hidden" name="collations[<?php echo $i; ?>]"
value="<?php if(isset($tbl_fields_collation[$i]))echo $tbl_fields_collation[$i]; ?>" />
</td></tr>
<?php
}//end for
?>
</tbody>
</table>
<?php
/*
* Other inputs like data label and mode go after selection of column criteria
*/
//Set default datalabel if not selected
if (isset($zoom_submit) && $inputs[0] != 'pma_null' && $inputs[1] != 'pma_null') {
if ($dataLabel == '') {
$dataLabel = PMA_getDisplayField($db, $table);
}
}
?>
<table class="data">
<tr><td><label for="dataLabel"><?php echo __("Use this column to label each point"); ?></label></td>
<td><select name="dataLabel" id='dataLabel' >
<option value = ''> <?php echo __('None'); ?> </option>
<?php
for ($j = 0; $j < $fields_cnt; $j++) {
if (isset($dataLabel) && $dataLabel == htmlspecialchars($fields_list[$j])) {
?>
<option value="<?php echo htmlspecialchars($fields_list[$j]);?>" selected="selected">
<?php echo htmlspecialchars($fields_list[$j]);?></option>
<?php
} else {
?>
<option value="<?php echo htmlspecialchars($fields_list[$j]);?>" >
<?php echo htmlspecialchars($fields_list[$j]);?></option>
<?php
}
}
?>
</select>
</td></tr>
<tr><td><label for="maxRowPlotLimit"><?php echo __("Maximum rows to plot"); ?></label></td>
<td>
<?php
echo '<input type="text" name="maxPlotLimit" id="maxRowPlotLimit" value="';
if (! empty($maxPlotLimit)) {
echo htmlspecialchars($maxPlotLimit);
} else {
echo $GLOBALS['cfg']['maxRowPlotLimit'];
}
echo '" /></td></tr>';
?>
</table>
</fieldset>
<fieldset class="tblFooters">
<input type="hidden" name="max_number_of_fields"
value="<?php echo $fields_cnt; ?>" />
<input type="submit" name="zoom_submit" id="inputFormSubmitId" value="<?php echo __('Go'); ?>" />
</fieldset>
</form>
</fieldset>
<?php
/*
* Handle the input criteria and generate the query result
* Form for displaying query results
*/
if (isset($zoom_submit) && $inputs[0] != 'pma_null' && $inputs[1] != 'pma_null' && $inputs[0] != $inputs[1]) {
/*
* Query generation part
*/
$w = $data = array();
$sql_query = 'SELECT *';
//Add the table
$sql_query .= ' FROM ' . PMA_backquote($table);
for ($i = 0; $i < 4; $i++) {
if ($inputs[$i] == 'pma_null') {
continue;
}
$tmp = array();
// The where clause
$charsets = array();
$cnt_func = count($zoomFunc[$i]);
$func_type = $zoomFunc[$i];
list($charsets[$i]) = explode('_', $collations[$i]);
$unaryFlag = (isset($GLOBALS['cfg']['UnaryOperators'][$func_type])
&& $GLOBALS['cfg']['UnaryOperators'][$func_type] == 1)
? true
: false;
$whereClause = PMA_tbl_search_getWhereClause(
$fields[$i], $inputs[$i], $types[$i],
$collations[$i], $func_type, $unaryFlag
);
if ($whereClause) {
$w[] = $whereClause;
}
} // end for
if ($w) {
$sql_query .= ' WHERE ' . implode(' AND ', $w);
}
$sql_query .= ' LIMIT ' . $maxPlotLimit;
/*
* Query execution part
*/
$result = PMA_DBI_query($sql_query . ";", null, PMA_DBI_QUERY_STORE);
$fields_meta = PMA_DBI_get_fields_meta($result);
while ($row = PMA_DBI_fetch_assoc($result)) {
//Need a row with indexes as 0,1,2 for the PMA_getUniqueCondition hence using a temporary array
$tmpRow = array();
foreach ($row as $val) {
$tmpRow[] = $val;
}
//Get unique conditon on each row (will be needed for row update)
$uniqueCondition = PMA_getUniqueCondition($result, $fields_cnt, $fields_meta, $tmpRow, true);
//Append it to row array as where_clause
$row['where_clause'] = $uniqueCondition[0];
if ($dataLabel == $inputs[0] || $dataLabel == $inputs[1]) {
$data[] = array(
$inputs[0] => $row[$inputs[0]],
$inputs[1] => $row[$inputs[1]],
'where_clause' => $uniqueCondition[0]
);
} elseif ($dataLabel) {
$data[] = array(
$inputs[0] => $row[$inputs[0]],
$inputs[1] => $row[$inputs[1]],
$dataLabel => $row[$dataLabel],
'where_clause' => $uniqueCondition[0]
);
} else {
$data[] = array(
$inputs[0] => $row[$inputs[0]],
$inputs[1] => $row[$inputs[1]],
$dataLabel => '',
'where_clause' => $uniqueCondition[0]
);
}
}
/*
* Form for displaying point data and also the scatter plot
*/
?>
<form method="post" action="tbl_zoom_select.php" name="displayResultForm" id="zoom_display_form"
<?php echo ($GLOBALS['cfg']['AjaxEnable'] ? ' class="ajax"' : ''); ?>>
<?php echo PMA_generate_common_hidden_inputs($db, $table); ?>
<input type="hidden" name="goto" value="<?php echo $goto; ?>" />
<input type="hidden" name="back" value="tbl_zoom_select.php" />
<fieldset id="displaySection">
<legend><?php echo __('Browse/Edit the points') ?></legend>
<center>
<?php
//JSON encode the data(query result)
if (isset($zoom_submit) && ! empty($data)) {
?>
<div id="resizer">
<center><a href="#" onclick="displayHelp();"><?php echo __('How to use'); ?></a></center>
<div id="querydata" style="display:none">
<?php
echo json_encode($data);
?>
</div>
<div id="querychart"></div>
<button class="button-reset"><?php echo __('Reset zoom'); ?></button>
</div>
<?php
}
?>
</center>
<div id='dataDisplay' style="display:none">
<table>
<thead>
<tr>
<th> <?php echo __('Column'); ?> </th>
<th> <?php echo __('Null'); ?> </th>
<th> <?php echo __('Value'); ?> </th>
</tr>
</thead>
<tbody>
<?php
$odd_row = true;
for ($i = 4; $i < $fields_cnt + 4; $i++) {
$tbl_fields_type[$i] = $fields_type[$i - 4];
$fieldpopup = $fields_list[$i - 4];
$foreignData = PMA_getForeignData($foreigners, $fieldpopup, false, '', '');
?>
<tr class="noclick <?php echo $odd_row ? 'odd' : 'even'; $odd_row = ! $odd_row; ?>">
<th><?php echo htmlspecialchars($fields_list[$i - 4]); ?></th>
<th><?php echo ($fields_null[$i - 4] == 'YES')
? '<input type="checkbox" class="checkbox_null" name="fields_null[ '
. $i . ' ]" id="fields_null_id_' . $i . '" />'
: ''; ?>
</th>
<th> <?php
echo PMA_getForeignFields_Values(
$foreigners, $foreignData, $fieldpopup, $tbl_fields_type,
$i, $db, $table, $titles,
$GLOBALS['cfg']['ForeignKeyMaxLimit'], '', false, true
); ?>
</th>
</tr>
<?php
}
?>
</tbody>
</table>
</div>
<input type="hidden" id="queryID" name="sql_query" />
</form>
<?php
}
require './libraries/footer.inc.php';
?>
| fobia/srv-tools-phpmyadmin | tbl_zoom_select.php | PHP | gpl-2.0 | 17,745 | [
30522,
1026,
1029,
25718,
1013,
1008,
6819,
2213,
1024,
2275,
7818,
2696,
2497,
25430,
1027,
1018,
24529,
1027,
1018,
8541,
1027,
1018,
1024,
1008,
1013,
1013,
1008,
1008,
1008,
16024,
2795,
24095,
3945,
21628,
1008,
1008,
4653,
2795,
24095... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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 (version 1.7.0_17) on Thu Oct 24 15:10:37 CEST 2013 -->
<title>UdpListener</title>
<meta name="date" content="2013-10-24">
<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="UdpListener";
}
//-->
</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 class="navBarCell1Rev">Class</li>
<li><a href="class-use/UdpListener.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-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><a href="../../../../com/veraxsystems/vxipmi/transport/Messenger.html" title="interface in com.veraxsystems.vxipmi.transport"><span class="strong">Prev Class</span></a></li>
<li><a href="../../../../com/veraxsystems/vxipmi/transport/UdpMessage.html" title="class in com.veraxsystems.vxipmi.transport"><span class="strong">Next Class</span></a></li>
</ul>
<ul class="navList">
<li><a href="../../../../index.html?com/veraxsystems/vxipmi/transport/UdpListener.html" target="_top">Frames</a></li>
<li><a href="UdpListener.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">com.veraxsystems.vxipmi.transport</div>
<h2 title="Interface UdpListener" class="title">Interface UdpListener</h2>
</div>
<div class="contentContainer">
<div class="description">
<ul class="blockList">
<li class="blockList">
<dl>
<dt>All Known Implementing Classes:</dt>
<dd><a href="../../../../com/veraxsystems/vxipmi/sm/StateMachine.html" title="class in com.veraxsystems.vxipmi.sm">StateMachine</a></dd>
</dl>
<hr>
<br>
<pre>public interface <span class="strong">UdpListener</span></pre>
<div class="block">An interface for <a href="../../../../com/veraxsystems/vxipmi/transport/UdpMessenger.html" title="class in com.veraxsystems.vxipmi.transport"><code>UdpMessenger</code></a> listener.</div>
</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="overviewSummary" border="0" cellpadding="3" cellspacing="0" summary="Method Summary table, listing methods, and an explanation">
<caption><span>Methods</span><span class="tabEnd"> </span></caption>
<tr>
<th class="colFirst" scope="col">Modifier and Type</th>
<th class="colLast" scope="col">Method and Description</th>
</tr>
<tr class="altColor">
<td class="colFirst"><code>void</code></td>
<td class="colLast"><code><strong><a href="../../../../com/veraxsystems/vxipmi/transport/UdpListener.html#notifyMessage(com.veraxsystems.vxipmi.transport.UdpMessage)">notifyMessage</a></strong>(<a href="../../../../com/veraxsystems/vxipmi/transport/UdpMessage.html" title="class in com.veraxsystems.vxipmi.transport">UdpMessage</a> message)</code>
<div class="block">Notifies listener of the UDP message that was received.</div>
</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="notifyMessage(com.veraxsystems.vxipmi.transport.UdpMessage)">
<!-- -->
</a>
<ul class="blockListLast">
<li class="blockList">
<h4>notifyMessage</h4>
<pre>void notifyMessage(<a href="../../../../com/veraxsystems/vxipmi/transport/UdpMessage.html" title="class in com.veraxsystems.vxipmi.transport">UdpMessage</a> message)</pre>
<div class="block">Notifies listener of the UDP message that was received.</div>
<dl><dt><span class="strong">Parameters:</span></dt><dd><code>message</code> - - message received</dd></dl>
</li>
</ul>
</li>
</ul>
</li>
</ul>
</div>
</div>
<!-- ========= END OF CLASS DATA ========= -->
<!-- ======= 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 class="navBarCell1Rev">Class</li>
<li><a href="class-use/UdpListener.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-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><a href="../../../../com/veraxsystems/vxipmi/transport/Messenger.html" title="interface in com.veraxsystems.vxipmi.transport"><span class="strong">Prev Class</span></a></li>
<li><a href="../../../../com/veraxsystems/vxipmi/transport/UdpMessage.html" title="class in com.veraxsystems.vxipmi.transport"><span class="strong">Next Class</span></a></li>
</ul>
<ul class="navList">
<li><a href="../../../../index.html?com/veraxsystems/vxipmi/transport/UdpListener.html" target="_top">Frames</a></li>
<li><a href="UdpListener.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 ======= -->
</body>
</html>
| zhoujinl/jIPMI | doc/com/veraxsystems/vxipmi/transport/UdpListener.html | HTML | gpl-3.0 | 7,977 | [
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... |
/*
* CT30A5001 Network Programming
* addresses.c, STCP server and client example
*
* Contains functions for getting own addresses for the SCTP example
*
* Author:
* Jussi Laakkonen
* 1234567
* jussi.laakkonen@lut.fi
*/
#include "addresses.h"
struct sockaddr* get_own_addresses_gai(int* count, char* port)
{
int status = 0, icount = 0, strsizetotal = 0;
struct addrinfo searchinfo = { .ai_flags = AI_PASSIVE|AI_NUMERICHOST|AI_NUMERICSERV,
.ai_family = PF_UNSPEC,
.ai_socktype = SOCK_SEQPACKET,
.ai_protocol = IPPROTO_SCTP};
struct addrinfo *addresses = NULL, *iter = NULL;
char* addrbuffer = NULL;
#ifdef __DEBUG_EN
char ipstr[NI_MAXHOST] = { 0 };
#endif
if((status = getaddrinfo(NULL,port,&searchinfo,&addresses) != 0))
{
printf("%s\n",gai_strerror(status));
error_situation();
}
else
{
for(iter = addresses; iter != NULL; iter = iter->ai_next)
{
strsizetotal += iter->ai_addrlen; // The new total size for the buffer
if(!addrbuffer) addrbuffer = (char*)malloc(iter->ai_addrlen); // Not allocated
else addrbuffer = (char*)realloc(addrbuffer,strsizetotal); // Increase allocation
// Copy the address structure into the buffer
memcpy(&addrbuffer[strsizetotal-(iter->ai_addrlen)],iter->ai_addr, iter->ai_addrlen);
#ifdef __DEBUG_EN
memset(&ipstr,0,NI_MAXHOST);
if(getnameinfo(iter->ai_addr,
iter->ai_addrlen,
ipstr,
NI_MAXHOST,
NULL,
0,
NI_NUMERICHOST) < 0 )
print_host(icount,iter->ai_family,NULL,NULL);
else print_host(icount,iter->ai_family,NULL,ipstr);
#endif
icount++;
}
}
if(addresses) freeaddrinfo(addresses);
*count = icount;
return (struct sockaddr*)addrbuffer;
}
struct sockaddr* get_own_addresses_gia(int* count, int port, int noloopback, int onlyrunning)
{
struct ifaddrs *ifaddr = NULL, *ifa = NULL;
int family = 0, strsizetotal = 0;
#ifdef __DEBUG_EN
int s = 0;
char host[NI_MAXHOST] = {0};
#endif
char *addrbuffer = NULL;
// Get all addresses for every interface
if (getifaddrs(&ifaddr) == -1)
{
error_situation();
return NULL;
}
int icount = 0;
for (ifa = ifaddr; ifa != NULL; ifa = ifa->ifa_next)
{
family = ifa->ifa_addr->sa_family;
// Only addresses supporting IPv4 or IPv6
if (family == AF_INET || family == AF_INET6)
{
// Allow only active interfaces, ignore local
int runningflag = 0, loopbackflag = 0;
if(onlyrunning) runningflag |= IFF_RUNNING;
else runningflag |= IFF_UP;
if(noloopback) loopbackflag |= IFF_LOOPBACK;
if(!(ifa->ifa_flags & loopbackflag) && (ifa->ifa_flags & runningflag))
{
icount++;
// Size of the current structure
int nsize = (family == AF_INET) ?
sizeof(struct sockaddr_in) :
(family == AF_INET6) ?
sizeof(struct sockaddr_in6) :
0 ;
strsizetotal += nsize; // The new total size for the buffer
if(!addrbuffer) addrbuffer = (char*)malloc(nsize); // Not allocated
else addrbuffer = (char*)realloc(addrbuffer,strsizetotal);
// IPv4
if(family == AF_INET)
{
struct sockaddr_in* v4addr = (struct sockaddr_in*)ifa->ifa_addr;
// Set port as sctp_bindx requires port to be same in each structure
v4addr->sin_port = htons(port);
v4addr->sin_family = family;
// Copy the IPv4 address structure into the buffer
memcpy(&addrbuffer[strsizetotal-nsize],v4addr, nsize);
}
// Otherwise IPv6
else if(family == AF_INET6)
{
struct sockaddr_in6* v6addr = (struct sockaddr_in6*)ifa->ifa_addr;
// Set port as sctp_bindx requires port to be same in each
v6addr->sin6_port = htons(port);
v6addr->sin6_family = family;
// Copy the IPv6 address structure into the buffer
memcpy(&addrbuffer[strsizetotal-nsize],v6addr, nsize);
}
else printf("Unknown address family: %d IGNORED\n", family);
#ifdef __DEBUG_EN
// Get and print the IP address
if((s = getnameinfo(ifa->ifa_addr,
(family == AF_INET) ? sizeof(struct sockaddr_in) : sizeof(struct sockaddr_in6),
host, NI_MAXHOST, NULL, 0, NI_NUMERICHOST)) == 0)
print_host(icount,family,ifa->ifa_name,host);
#endif
}
}
}
freeifaddrs(ifaddr);
*count = icount;
return (struct sockaddr *)addrbuffer;
}
struct sockaddr* get_own_addresses_combined(int* count, char* port, int noloopback, int onlyrunning)
{
struct ifaddrs *ifaddr = NULL, *ifa = NULL;
struct addrinfo *result = NULL;
struct addrinfo hints = { .ai_flags = AI_NUMERICHOST,
.ai_family = PF_UNSPEC,
.ai_socktype = SOCK_SEQPACKET,
.ai_protocol = IPPROTO_SCTP };
int family = 0, strsizetotal = 0;
char host[NI_MAXHOST] = {0};
char *addrbuffer = NULL;
// Get all addresses for every interface
if (getifaddrs(&ifaddr) == -1)
{
error_situation();
return NULL;
}
int icount = 0;
for (ifa = ifaddr; ifa != NULL; ifa = ifa->ifa_next)
{
family = ifa->ifa_addr->sa_family;
// Allow only active interfaces, ignore local
int runningflag = 0, loopbackflag = 0;
if(onlyrunning) runningflag |= IFF_RUNNING;
else runningflag |= IFF_UP;
if(noloopback) loopbackflag |= IFF_LOOPBACK;
if(!(ifa->ifa_flags & loopbackflag) && (ifa->ifa_flags & runningflag))
{
// Size of the current structure, this is protocol dependant
int nsize = (family == AF_INET) ?
sizeof(struct sockaddr_in) :
(family == AF_INET6) ?
sizeof(struct sockaddr_in6) :
0;
memset(&host,0,NI_MAXHOST);
// Get the IP for this structure
if(getnameinfo(ifa->ifa_addr,
nsize,
host,
NI_MAXHOST,
NULL,
0,
NI_NUMERICHOST) < 0)
continue;
// Fill in struct for this address
if(getaddrinfo(host,port,&hints,&result) < 0) {
freeaddrinfo(result);
result = NULL;
continue;
}
// Use the first
if(result) {
strsizetotal += result->ai_addrlen;
if(!addrbuffer) addrbuffer = (char*)malloc(result->ai_addrlen); // Not allocated
else addrbuffer = (char*)realloc(addrbuffer,strsizetotal);
memcpy(&addrbuffer[strsizetotal-(result->ai_addrlen)],
result->ai_addr,
result->ai_addrlen);
icount++; // One was added, increase counter
}
freeaddrinfo(result);
result = NULL;
#ifdef __DEBUG_EN
// Print the IP address
print_host(icount,family,ifa->ifa_name,host);
#endif
}
}
freeifaddrs(ifaddr);
*count = icount;
return (struct sockaddr *)addrbuffer;
}
int error_situation()
{
perror("Error");
return -1;
}
void print_host(int id,int family,char* iface, char* host) {
printf("%d:\t[%s]\t%s\t%s\n",
id,
(family == PF_INET ? "IPv4" : "IPv6"),
(iface == NULL ? "<?>" : iface),
(host == NULL ? "no IP" : host));
}
| HateBreed/Course-example-codes | sctp_demo/addresses.c | C | gpl-2.0 | 6,718 | [
30522,
1013,
1008,
1008,
14931,
14142,
2050,
29345,
2487,
2897,
4730,
1008,
11596,
1012,
1039,
1010,
2358,
21906,
8241,
1998,
7396,
2742,
1008,
1008,
3397,
4972,
2005,
2893,
2219,
11596,
2005,
1996,
8040,
25856,
2742,
1008,
1008,
3166,
1024... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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 "spec_helper"
describe "Relevance::Tarantula::HtmlReporter file output" do
before do
FileUtils.rm_rf(test_output_dir)
FileUtils.mkdir_p(test_output_dir)
@test_name = "test_user_pages"
Relevance::Tarantula::Result.next_number = 0
@success_results = (1..10).map do |index|
Relevance::Tarantula::Result.new(
:success => true,
:method => "get",
:url => "/widgets/#{index}",
:response => stub(:code => "200", :body => "<h1>header</h1>\n<p>text</p>"),
:referrer => "/random/#{rand(100)}",
:test_name => @test_name,
:log => <<-END,
Made-up stack trace:
/some_module/some_class.rb:697:in `bad_method'
/some_module/other_class.rb:12345677:in `long_method'
this link should be <a href="#">escaped</a>
blah blah blah
END
:data => "{:param1 => :value, :param2 => :another_value}"
)
end
@fail_results = (1..10).map do |index|
Relevance::Tarantula::Result.new(
:success => false,
:method => "get",
:url => "/widgets/#{index}",
:response => stub(:code => "500", :body => "<h1>header</h1>\n<p>text</p>"),
:referrer => "/random/#{rand(100)}",
:test_name => @test_name,
:log => <<-END,
Made-up stack trace:
/some_module/some_class.rb:697:in `bad_method'
/some_module/other_class.rb:12345677:in `long_method'
this link should be <a href="#">escaped</a>
blah blah blah
END
:data => "{:param1 => :value, :param2 => :another_value}"
)
end
@index = File.join(test_output_dir, "index.html")
FileUtils.rm_f @index
@detail = File.join(test_output_dir, @test_name,"1.html")
FileUtils.rm_f @detail
end
it "creates a final report based on tarantula results" do
Relevance::Tarantula::Result.any_instance.stubs(:rails_root).returns("STUB_ROOT")
reporter = Relevance::Tarantula::HtmlReporter.new(test_output_dir)
stub_puts_and_print(reporter)
(@success_results + @fail_results).each {|r| reporter.report(r)}
reporter.finish_report(@test_name)
File.exist?(@index).should be_true
end
it "creates a final report with links to detailed reports in subdirs" do
Relevance::Tarantula::Result.any_instance.stubs(:rails_root).returns("STUB_ROOT")
reporter = Relevance::Tarantula::HtmlReporter.new(test_output_dir)
stub_puts_and_print(reporter)
(@success_results + @fail_results).each {|r| reporter.report(r)}
reporter.finish_report(@test_name)
links = Hpricot(File.read(@index)).search('.left a')
links.each do |link|
link['href'].should match(/#{@test_name}\/\d+\.html/)
end
end
it "creates detailed reports based on tarantula results" do
Relevance::Tarantula::Result.any_instance.stubs(:rails_root).returns("STUB_ROOT")
reporter = Relevance::Tarantula::HtmlReporter.new(test_output_dir)
stub_puts_and_print(reporter)
(@success_results + @fail_results).each {|r| reporter.report(r)}
reporter.finish_report(@test_name)
File.exist?(@detail).should be_true
end
end
| codez/tarantula | spec/relevance/tarantula/html_reporter_spec.rb | Ruby | mit | 3,088 | [
30522,
5478,
1000,
28699,
1035,
2393,
2121,
1000,
6235,
1000,
21923,
1024,
1024,
10225,
3372,
7068,
1024,
1024,
16129,
2890,
6442,
2121,
5371,
6434,
1000,
2079,
2077,
2079,
5371,
21823,
4877,
1012,
28549,
1035,
21792,
1006,
3231,
1035,
6434... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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... |
/*
************************************************************************************************************************
* eNand
* Nand flash driver scan module
*
* Copyright(C), 2008-2009, SoftWinners Microelectronic Co., Ltd.
* All Rights Reserved
*
* File Name : nand_scan.c
*
* Author : Kevin.z
*
* Version : v0.1
*
* Date : 2008.03.27
*
* Description : This file scan the nand flash storage system, analyze the nand flash type
* and initiate the physical architecture parameters.
*
* Others : None at present.
*
*
* History :
*
* <Author> <time> <version> <description>
*
* Kevin.z 2008.03.27 0.1 build the file
*
************************************************************************************************************************
*/
#include "../include/nand_drv_cfg.h"
#include "../include/nand_type.h"
#include "../include/nand_physic.h"
#include "../include/nfc.h"
extern struct __NandStorageInfo_t NandStorageInfo;
extern __s32 BOOT_NandGetPara(boot_nand_para_t *param, __u32 size);
void _InitNandPhyInfo(boot_nand_para_t *nand_info)
{
__u32 i;
NandStorageInfo.ChannelCnt = nand_info->ChannelCnt ;
NandStorageInfo.ChipCnt = nand_info->ChipCnt ;
NandStorageInfo.ChipConnectInfo = nand_info->ChipConnectInfo ;
NandStorageInfo.RbCnt = nand_info->RbCnt ;
NandStorageInfo.RbConnectInfo = nand_info->RbConnectInfo ;
NandStorageInfo.RbConnectMode = nand_info->RbConnectMode ;
NandStorageInfo.BankCntPerChip = nand_info->BankCntPerChip ;
NandStorageInfo.DieCntPerChip = nand_info->DieCntPerChip ;
NandStorageInfo.PlaneCntPerDie = nand_info->PlaneCntPerDie ;
NandStorageInfo.SectorCntPerPage = nand_info->SectorCntPerPage ;
NandStorageInfo.PageCntPerPhyBlk = nand_info->PageCntPerPhyBlk ;
NandStorageInfo.BlkCntPerDie = nand_info->BlkCntPerDie ;
NandStorageInfo.OperationOpt = nand_info->OperationOpt & (NAND_LSB_PAGE_TYPE
| NAND_RANDOM | NAND_READ_RETRY);
NandStorageInfo.FrequencePar = nand_info->FrequencePar ;
NandStorageInfo.EccMode = nand_info->EccMode ;
NandStorageInfo.ValidBlkRatio = nand_info->ValidBlkRatio ;
NandStorageInfo.ReadRetryType = nand_info->ReadRetryType ;
NandStorageInfo.DDRType = nand_info->DDRType ;
for(i=0;i<8;i++)
NandStorageInfo.NandChipId[i] = nand_info->NandChipId[i] ;
}
/*
************************************************************************************************************************
* SEARCH NAND PHYSICAL ARCHITECTURE PARAMETER
*
*Description: Search the nand flash physical architecture parameter from the parameter table
* by nand chip ID.
*
*Arguments : pNandID the pointer to nand flash chip ID;
* pNandArchiInfo the pointer to nand flash physical architecture parameter.
*
*Return : search result;
* = 0 search successful, find the parameter in the table;
* < 0 search failed, can't find the parameter in the table.
************************************************************************************************************************
*/
__s32 _CheckNandID(__u8 *pNandID)
{
__s32 j=0;
//search the nand architecture parameter from the given manufacture nand table by nand ID
while(1)
{
for(j=0; j<6; j++)
{
//0xff is matching all ID value
if((pNandID[j] != NandStorageInfo.NandChipId[j])&&(NandStorageInfo.NandChipId[j]!=0xff))
break;
}
if(j==6)
{
/*6 bytes of the nand chip ID are all matching, search parameter successful*/
return 0;
}
break;
}
//search nand architecture parameter failed
return -1;
}
/*
************************************************************************************************************************
* ANALYZE NAND FLASH STORAGE SYSTEM
*
*Description: Analyze nand flash storage system, generate the nand flash physical
* architecture parameter and connect information.
*
*Arguments : none
*
*Return : analyze result;
* = 0 analyze successful;
* < 0 analyze failed, can't recognize or some other error.
************************************************************************************************************************
*/
__s32 BOOT_AnalyzeNandSystem(void)
{
__s32 result;
__u8 tmpChipID[8];
boot_nand_para_t nand_info;
if( BOOT_NandGetPara( &nand_info, sizeof(boot_nand_para_t) ) != 0 ){
return -1;
}
_InitNandPhyInfo(&nand_info);
//reset the nand flash chip on boot chip select
result = PHY_ResetChip(BOOT_CHIP_SELECT_NUM);
result |= PHY_SynchBank(BOOT_CHIP_SELECT_NUM, SYNC_CHIP_MODE);
if(result)
return -1;
//read nand flash chip ID from boot chip
result = PHY_ReadNandId(BOOT_CHIP_SELECT_NUM, tmpChipID);
if(result)
return -1;
//check nand ID
result = _CheckNandID(tmpChipID);
if(result)
return -1;
/*configure page size*/
{
NFC_INIT_INFO nfc_info;
nfc_info.bus_width = 0x0;
nfc_info.ce_ctl = 0x0;
nfc_info.ce_ctl1 = 0x0;
nfc_info.debug = 0x0;
nfc_info.pagesize = SECTOR_CNT_OF_SINGLE_PAGE;
nfc_info.rb_sel = 1;
nfc_info.serial_access_mode = 1;
nfc_info.ddr_type = DDR_TYPE;
NFC_ChangMode(&nfc_info);
NandIndex = 0;
}
PHY_ChangeMode(1);
if( SUPPORT_READ_RETRY
&& ( (((READ_RETRY_TYPE>>16)&0xff) < 0x10)
|| (((READ_RETRY_TYPE>>16)&0xff) == 0x40)
|| (((READ_RETRY_TYPE>>16)&0xff) == 0x41) )) //boot0 support hynix, micron readretry
{
NFC_ReadRetryInit(READ_RETRY_TYPE);
PHY_GetDefaultParam(0);
}
else
{
NandStorageInfo.ReadRetryType = 0;
}
return 0;
}
__u32 NAND_Getlsbpage_type(void)
{
//PRINT("%x\n",NandStorageInfo.OperationOpt);
//PRINT("LSB TYPE:%x\n",(((0xff<<12) & NandStorageInfo.OperationOpt)>>12));
return (((0xff<<12) & NandStorageInfo.OperationOpt)>>12);
}
__u32 Nand_Is_lsb_page(__u32 page)
{
__u32 retry_mode;
__u32 NAND_LSBPAGE_TYPE;
NAND_LSBPAGE_TYPE = NAND_Getlsbpage_type();
if(!NAND_LSBPAGE_TYPE)
{
return 1;//every page is lsb page
}
if(NAND_LSBPAGE_TYPE == 0x20) //samsung 25nm
{
if(page==0)
return 1;
if(page==PAGE_CNT_OF_PHY_BLK-1)
return 0;
if(page%2==1)
return 1;
return 0;
}
if((NAND_LSBPAGE_TYPE==0x01))//hynix 26nm,20nm
{
if((page==0)||(page==1))
return 1;
if((page==PAGE_CNT_OF_PHY_BLK-2)||(page==PAGE_CNT_OF_PHY_BLK-1))
return 0;
if((page%4 == 2)||(page%4 == 3))
return 1;
return 0;
}
if((NAND_LSBPAGE_TYPE==0x02))//hynix 16nm
{
if(page==0)
return 1;
if(page==PAGE_CNT_OF_PHY_BLK-1)
return 0;
if(page%2 == 1)
return 1;
return 0;
}
if(NAND_LSBPAGE_TYPE==0x10)//toshiba 2xnm 19nm 1ynm
{
if(page==0)
return 1;
if(page==PAGE_CNT_OF_PHY_BLK-1)
return 0;
if(page%2 == 1)
return 1;
return 0;
}
if(NAND_LSBPAGE_TYPE==0x40)//micron 20nm 29f64g08cbaba
{
if((page==0)||(page==1))
return 1;
if((page==PAGE_CNT_OF_PHY_BLK-2)||(page==PAGE_CNT_OF_PHY_BLK-1))
return 0;
if((page%4 == 2)||(page%4 == 3))
return 1;
return 0;
}
if(NAND_LSBPAGE_TYPE==0x41)//micron 20nm 29f32g08cbada
{
if((page==2)||(page==3))
return 1;
if((page==PAGE_CNT_OF_PHY_BLK-2)||(page==PAGE_CNT_OF_PHY_BLK-1))
return 1;
if((page%4 == 0)||(page%4 == 1))
return 1;
return 0;
}
if(NAND_LSBPAGE_TYPE==0x42)//micron 16nm l95b
{
if((page==0)||(page==1)||(page==2)||(page==3)||(page==4)||(page==5)||(page==7)||(page==8)||(page==509))
return 1;
if((page==6)||(page==508)||(page==511))
return 0;
if((page%4 == 2)||(page%4 == 3))
return 1;
return 0;
}
if(NAND_LSBPAGE_TYPE==0x50)//intel JS29F64G08ACMF3
{
if((page==0)||(page==1))
return 1;
if((page==PAGE_CNT_OF_PHY_BLK-2)||(page==PAGE_CNT_OF_PHY_BLK-1))
return 0;
if((page%4 == 2)||(page%4 == 3))
return 1;
return 0;
}
if(NAND_LSBPAGE_TYPE==0x30)//sandisk 2xnm 19nm 1ynm
{
if(page==0)
return 1;
if(page==PAGE_CNT_OF_PHY_BLK-1)
return 0;
if(page%2 == 1)
return 1;
return 0;
}
}
__u32 NAND_GetLsbblksize(void)
{
__u32 i,count;
count=0;
if(NAND_Getlsbpage_type()==0)
return NandStorageInfo.PageCntPerPhyBlk*NandStorageInfo.SectorCntPerPage*512;
for(i=0;i<NandStorageInfo.PageCntPerPhyBlk;i++)
{
if(Nand_Is_lsb_page(i))
count++;
}
return count*NandStorageInfo.SectorCntPerPage*512;
}
| OLIMEX/DIY-LAPTOP | SOFTWARE/A64-TERES/u-boot_new/arch/arm/cpu/armv8/wine/nand/nand_bsp/nfc_for_boot0/src/nand_scan_for_boot.c | C | apache-2.0 | 8,760 | [
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... |
# TaskTreeBonsai
npm install
npm start | itiya/TaskTreeBonsai | README.md | Markdown | mit | 38 | [
30522,
1001,
4708,
13334,
11735,
15816,
27937,
2213,
16500,
27937,
2213,
2707,
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,
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... |
<!--Navigation bar-->
<nav class="navbar navbar-default navbar-fixed-top">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#myNavbar">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" [routerLink]="['/']">Club Membership</a>
</div>
<div class="collapse navbar-collapse" id="myNavbar">
<ul class="nav navbar-nav navbar-right">
<li><a [routerLink]="['/']">ABOUT</a></li>
<li><a [routerLink]="['/']">SERVICES</a></li>
<li><a [routerLink]="['/']">CLUBS</a></li>
<li><a [routerLink]="['/']">FORM</a></li>
</ul>
</div>
</div>
</nav> | muronchik/clubmembership-angular | src/app/components/nav/nav-custom.component.html | HTML | mit | 803 | [
30522,
1026,
999,
1011,
1011,
9163,
3347,
1011,
1011,
1028,
1026,
6583,
2615,
2465,
1027,
1000,
6583,
26493,
2906,
6583,
26493,
2906,
1011,
12398,
6583,
26493,
2906,
1011,
4964,
1011,
2327,
1000,
1028,
1026,
4487,
2615,
2465,
1027,
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... |
<!--
* 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.
-->
<style type="text/css"> @import url( rewriter1.css ); </style>
<link rel="stylesheet" type="text/css" href="rewriter2.css"/>
<p>A simple gadget to demonstrate the content rewriter</p>
<div>
This is a URL in content that was not rewritten http://www.notrewritten.com
</div>
<div id="backgrdiv">
This div has a background <br/> image from imported CSS
</div>
<div id="backgrdiv2">
This div has a background <br/> image from linked CSS
</div>
<p> This <img id="rewriteimg" src="feather.png" alt="If you can read this there is a problem"/> is an image tag that was rewritten</p>
<p id="jstarget1">If you can read this there is a problem</p>
<p id="jstarget2">If you can read this there is a problem</p>
<script type="text/javascript" src="rewriter1.js"></script>
<script type="text/javascript" src="rewriter2.js"></script>
| ROLE/widget-store | src/main/drupal/sites/all/libraries/shindig2.5beta/content/samplecontainer/examples/rewriter/rewriteron.html | HTML | gpl-2.0 | 1,635 | [
30522,
1026,
999,
1011,
1011,
1008,
7000,
2000,
1996,
15895,
4007,
3192,
1006,
2004,
2546,
1007,
2104,
2028,
1008,
2030,
2062,
12130,
6105,
10540,
1012,
2156,
1996,
5060,
5371,
1008,
5500,
2007,
2023,
2147,
2005,
3176,
2592,
1008,
4953,
9... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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>
{% include head.html %}
<body>
{%include banner.html%}
{%include middle.html%}
<!-- <script src="{{ site.baseurl }}/js/index.js"></script> -->
</body>
<footer></footer>
</html>
| huangyuanyazi/huangyuanyazi.github.io | _layouts/show.html | HTML | mit | 215 | [
30522,
1026,
999,
9986,
13874,
16129,
1028,
1026,
16129,
1028,
1063,
1003,
2421,
2132,
1012,
16129,
1003,
1065,
1026,
2303,
1028,
1063,
1003,
2421,
9484,
1012,
16129,
1003,
1065,
1063,
1003,
2421,
2690,
1012,
16129,
1003,
1065,
1026,
999,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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... |
/*****************************************************************************
*
* Nagios run command utilities
*
* License: GPL
* Copyright (c) 2005-2014 Nagios Plugins Development Team
*
* Description :
*
* A simple interface to executing programs from other programs, using an
* optimized and safe popen()-like implementation. It is considered safe
* in that no shell needs to be spawned and the environment passed to the
* execve()'d program is essentially empty.
*
* The code in this file is a derivative of popen.c which in turn was taken
* from "Advanced Programming for the Unix Environment" by W. Richard Stevens.
*
* Care has been taken to make sure the functions are async-safe. The one
* function which isn't is np_runcmd_init() which it doesn't make sense to
* call twice anyway, so the api as a whole should be considered async-safe.
*
*
* 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/>.
*
*
*****************************************************************************/
#define NAGIOSPLUG_API_C 1
/** includes **/
#include "runcmd.h"
#ifdef HAVE_SYS_WAIT_H
# include <sys/wait.h>
#endif
/** macros **/
#ifndef WEXITSTATUS
# define WEXITSTATUS(stat_val) ((unsigned)(stat_val) >> 8)
#endif
#ifndef WIFEXITED
# define WIFEXITED(stat_val) (((stat_val) & 255) == 0)
#endif
/* 4.3BSD Reno <signal.h> doesn't define SIG_ERR */
#if defined(SIG_IGN) && !defined(SIG_ERR)
# define SIG_ERR ((Sigfunc *)-1)
#endif
/* This variable must be global, since there's no way the caller
* can forcibly slay a dead or ungainly running program otherwise.
* Multithreading apps and plugins can initialize it (via NP_RUNCMD_INIT)
* in an async safe manner PRIOR to calling np_runcmd() for the first time.
*
* The check for initialized values is atomic and can
* occur in any number of threads simultaneously. */
static pid_t *np_pids = NULL;
/* Try sysconf(_SC_OPEN_MAX) first, as it can be higher than OPEN_MAX.
* If that fails and the macro isn't defined, we fall back to an educated
* guess. There's no guarantee that our guess is adequate and the program
* will die with SIGSEGV if it isn't and the upper boundary is breached. */
#ifdef _SC_OPEN_MAX
static long maxfd = 0;
#elif defined(OPEN_MAX)
# define maxfd OPEN_MAX
#else /* sysconf macro unavailable, so guess (may be wildly inaccurate) */
# define maxfd 256
#endif
/** prototypes **/
static int np_runcmd_open(const char *, int *, int *)
__attribute__((__nonnull__(1, 2, 3)));
static int np_fetch_output(int, output *, int)
__attribute__((__nonnull__(2)));
static int np_runcmd_close(int);
/* prototype imported from utils.h */
extern void die (int, const char *, ...)
__attribute__((__noreturn__,__format__(__printf__, 2, 3)));
/* this function is NOT async-safe. It is exported so multithreaded
* plugins (or other apps) can call it prior to running any commands
* through this api and thus achieve async-safeness throughout the api */
void np_runcmd_init(void)
{
#ifndef maxfd
if(!maxfd && (maxfd = sysconf(_SC_OPEN_MAX)) < 0) {
/* possibly log or emit a warning here, since there's no
* guarantee that our guess at maxfd will be adequate */
maxfd = 256;
}
#endif
if(!np_pids) np_pids = calloc(maxfd, sizeof(pid_t));
}
/* Start running a command */
static int
np_runcmd_open(const char *cmdstring, int *pfd, int *pfderr)
{
char *env[2];
char *cmd = NULL;
char **argv = NULL;
char *str;
int argc;
size_t cmdlen;
pid_t pid;
#ifdef RLIMIT_CORE
struct rlimit limit;
#endif
int i = 0;
if(!np_pids) NP_RUNCMD_INIT;
env[0] = strdup("LC_ALL=C");
env[1] = '\0';
/* if no command was passed, return with no error */
if (cmdstring == NULL)
return -1;
/* make copy of command string so strtok() doesn't silently modify it */
/* (the calling program may want to access it later) */
cmdlen = strlen(cmdstring);
if((cmd = malloc(cmdlen + 1)) == NULL) return -1;
memcpy(cmd, cmdstring, cmdlen);
cmd[cmdlen] = '\0';
/* This is not a shell, so we don't handle "???" */
if (strstr (cmdstring, "\"")) return -1;
/* allow single quotes, but only if non-whitesapce doesn't occur on both sides */
if (strstr (cmdstring, " ' ") || strstr (cmdstring, "'''"))
return -1;
/* each arg must be whitespace-separated, so args can be a maximum
* of (len / 2) + 1. We add 1 extra to the mix for NULL termination */
argc = (cmdlen >> 1) + 2;
argv = calloc(sizeof(char *), argc);
if (argv == NULL) {
printf ("%s\n", _("Could not malloc argv array in popen()"));
return -1;
}
/* get command arguments (stupidly, but fairly quickly) */
while (cmd) {
str = cmd;
str += strspn (str, " \t\r\n"); /* trim any leading whitespace */
if (strstr (str, "'") == str) { /* handle SIMPLE quoted strings */
str++;
if (!strstr (str, "'")) return -1; /* balanced? */
cmd = 1 + strstr (str, "'");
str[strcspn (str, "'")] = 0;
}
else {
if (strpbrk (str, " \t\r\n")) {
cmd = 1 + strpbrk (str, " \t\r\n");
str[strcspn (str, " \t\r\n")] = 0;
}
else {
cmd = NULL;
}
}
if (cmd && strlen (cmd) == strspn (cmd, " \t\r\n"))
cmd = NULL;
argv[i++] = str;
}
if (pipe(pfd) < 0 || pipe(pfderr) < 0 || (pid = fork()) < 0)
return -1; /* errno set by the failing function */
/* child runs exceve() and _exit. */
if (pid == 0) {
#ifdef RLIMIT_CORE
/* the program we execve shouldn't leave core files */
getrlimit (RLIMIT_CORE, &limit);
limit.rlim_cur = 0;
setrlimit (RLIMIT_CORE, &limit);
#endif
close (pfd[0]);
if (pfd[1] != STDOUT_FILENO) {
dup2 (pfd[1], STDOUT_FILENO);
close (pfd[1]);
}
close (pfderr[0]);
if (pfderr[1] != STDERR_FILENO) {
dup2 (pfderr[1], STDERR_FILENO);
close (pfderr[1]);
}
/* close all descriptors in np_pids[]
* This is executed in a separate address space (pure child),
* so we don't have to worry about async safety */
for (i = 0; i < maxfd; i++)
if(np_pids[i] > 0)
close (i);
execve (argv[0], argv, env);
_exit (STATE_UNKNOWN);
}
/* parent picks up execution here */
/* close childs descriptors in our address space */
close(pfd[1]);
close(pfderr[1]);
/* tag our file's entry in the pid-list and return it */
np_pids[pfd[0]] = pid;
return pfd[0];
}
static int
np_runcmd_close(int fd)
{
int status;
pid_t pid;
/* make sure this fd was opened by popen() */
if(fd < 0 || fd > maxfd || !np_pids || (pid = np_pids[fd]) == 0)
return -1;
np_pids[fd] = 0;
if (close (fd) == -1) return -1;
/* EINTR is ok (sort of), everything else is bad */
while (waitpid (pid, &status, 0) < 0)
if (errno != EINTR) return -1;
/* return child's termination status */
return (WIFEXITED(status)) ? WEXITSTATUS(status) : -1;
}
void
runcmd_timeout_alarm_handler (int signo)
{
size_t i;
if (signo == SIGALRM)
printf("%s - Plugin timed out while executing system call\n", state_text(timeout_state));
if(np_pids) for(i = 0; i < maxfd; i++) {
if(np_pids[i] != 0) kill(np_pids[i], SIGKILL);
}
exit (timeout_state);
}
static int
np_fetch_output(int fd, output *op, int flags)
{
size_t len = 0, i = 0, lineno = 0;
size_t rsf = 6, ary_size = 0; /* rsf = right shift factor, dec'ed uncond once */
char *buf = NULL;
int ret;
char tmpbuf[4096];
op->buf = NULL;
op->buflen = 0;
while((ret = read(fd, tmpbuf, sizeof(tmpbuf))) > 0) {
len = (size_t)ret;
op->buf = realloc(op->buf, op->buflen + len + 1);
memcpy(op->buf + op->buflen, tmpbuf, len);
op->buflen += len;
i++;
}
if(ret < 0) {
printf("read() returned %d: %s\n", ret, strerror(errno));
return ret;
}
/* some plugins may want to keep output unbroken, and some commands
* will yield no output, so return here for those */
if(flags & RUNCMD_NO_ARRAYS || !op->buf || !op->buflen)
return op->buflen;
/* and some may want both */
if(flags & RUNCMD_NO_ASSOC) {
buf = malloc(op->buflen);
memcpy(buf, op->buf, op->buflen);
}
else buf = op->buf;
op->line = NULL;
op->lens = NULL;
i = 0;
while(i < op->buflen) {
/* make sure we have enough memory */
if(lineno >= ary_size) {
/* ary_size must never be zero */
do {
ary_size = op->buflen >> --rsf;
} while(!ary_size);
op->line = realloc(op->line, ary_size * sizeof(char *));
op->lens = realloc(op->lens, ary_size * sizeof(size_t));
}
/* set the pointer to the string */
op->line[lineno] = &buf[i];
/* hop to next newline or end of buffer */
while(buf[i] != '\n' && i < op->buflen) i++;
buf[i] = '\0';
/* calculate the string length using pointer difference */
op->lens[lineno] = (size_t)&buf[i] - (size_t)op->line[lineno];
lineno++;
i++;
}
return lineno;
}
int
np_runcmd(const char *cmd, output *out, output *err, int flags)
{
int fd, pfd_out[2], pfd_err[2];
/* initialize the structs */
if(out) memset(out, 0, sizeof(output));
if(err) memset(err, 0, sizeof(output));
if((fd = np_runcmd_open(cmd, pfd_out, pfd_err)) == -1)
die (STATE_UNKNOWN, _("Could not open pipe: %s\n"), cmd);
if(out) out->lines = np_fetch_output(pfd_out[0], out, flags);
if(err) err->lines = np_fetch_output(pfd_err[0], err, flags);
return np_runcmd_close(fd);
}
| barqshasbite/nagios-plugins | plugins/runcmd.c | C | gpl-3.0 | 9,671 | [
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... |
import config from '../../config/common';
import Context from '../../src/server/context';
import range from 'range';
/**
* Create an instance of Context with the given list of blacklisted IPs.
*
* @param {Array=} blacklistIPs Array of IPs to blacklist in the context.
* @returns {Object} Initialized context object.
*/
function create(blacklistIPs) {
const ctx = {
blacklist: Context.prototype.initBlacklistCache(),
db: {},
yubikey: Context.prototype.initYubikeyValidator()
};
ctx.allu = {
template: () => {}
};
range
.range(0, config.blacklist.maxFailedAttempts + 1)
.forEach(() => (blacklistIPs || []).forEach((ip) => ctx.blacklist.increment(ip)));
return ctx;
}
const contextFactory = {
create
};
export default contextFactory;
| LINKIWI/apache-auth | test/util/context-factory.js | JavaScript | mit | 780 | [
30522,
12324,
9530,
8873,
2290,
2013,
1005,
1012,
1012,
1013,
1012,
1012,
1013,
9530,
8873,
2290,
1013,
2691,
1005,
1025,
12324,
6123,
2013,
1005,
1012,
1012,
1013,
1012,
1012,
1013,
5034,
2278,
1013,
8241,
1013,
6123,
1005,
1025,
12324,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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 LWJGL. All rights reserved.
* License terms: https://www.lwjgl.org/license
* MACHINE GENERATED FILE, DO NOT EDIT
*/
package org.lwjgl.util.opus;
import javax.annotation.*;
import java.nio.*;
import org.lwjgl.*;
import org.lwjgl.system.*;
import static org.lwjgl.system.Checks.*;
import static org.lwjgl.system.MemoryUtil.*;
import static org.lwjgl.system.MemoryStack.*;
/**
* The callbacks used to access non-{@code FILE} stream resources.
*
* <p>The function prototypes are basically the same as for the stdio functions {@code fread()}, {@code fseek()}, {@code ftell()}, and {@code fclose()}. The
* differences are that the {@code FILE *} arguments have been replaced with a {@code void *}, which is to be used as a pointer to whatever internal data
* these functions might need, that {@code seek} and {@code tell} take and return 64-bit offsets, and that {@code seek} <em>must</em> return {@code -1} if
* the stream is unseekable.</p>
*
* <h3>Layout</h3>
*
* <pre><code>
* struct OpusFileCallbacks {
* {@link OPReadFuncI op_read_func} {@link #read};
* {@link OPSeekFuncI op_seek_func} {@link #seek};
* {@link OPTellFuncI op_tell_func} {@link #tell};
* {@link OPCloseFuncI op_close_func} {@link #close$ close};
* }</code></pre>
*/
public class OpusFileCallbacks extends Struct implements NativeResource {
/** The struct size in bytes. */
public static final int SIZEOF;
/** The struct alignment in bytes. */
public static final int ALIGNOF;
/** The struct member offsets. */
public static final int
READ,
SEEK,
TELL,
CLOSE;
static {
Layout layout = __struct(
__member(POINTER_SIZE),
__member(POINTER_SIZE),
__member(POINTER_SIZE),
__member(POINTER_SIZE)
);
SIZEOF = layout.getSize();
ALIGNOF = layout.getAlignment();
READ = layout.offsetof(0);
SEEK = layout.offsetof(1);
TELL = layout.offsetof(2);
CLOSE = layout.offsetof(3);
}
/**
* Creates a {@code OpusFileCallbacks} instance at the current position of the specified {@link ByteBuffer} container. Changes to the buffer's content will be
* visible to the struct instance and vice versa.
*
* <p>The created instance holds a strong reference to the container object.</p>
*/
public OpusFileCallbacks(ByteBuffer container) {
super(memAddress(container), __checkContainer(container, SIZEOF));
}
@Override
public int sizeof() { return SIZEOF; }
/** used to read data from the stream. This must not be {@code NULL}. */
@NativeType("op_read_func")
public OPReadFunc read() { return nread(address()); }
/** used to seek in the stream. This may be {@code NULL} if seeking is not implemented. */
@Nullable
@NativeType("op_seek_func")
public OPSeekFunc seek() { return nseek(address()); }
/** used to return the current read position in the stream. This may be {@code NULL} if seeking is not implemented. */
@Nullable
@NativeType("op_tell_func")
public OPTellFunc tell() { return ntell(address()); }
/** used to close the stream when the decoder is freed. This may be {@code NULL} to leave the stream open. */
@Nullable
@NativeType("op_close_func")
public OPCloseFunc close$() { return nclose$(address()); }
/** Sets the specified value to the {@link #read} field. */
public OpusFileCallbacks read(@NativeType("op_read_func") OPReadFuncI value) { nread(address(), value); return this; }
/** Sets the specified value to the {@link #seek} field. */
public OpusFileCallbacks seek(@Nullable @NativeType("op_seek_func") OPSeekFuncI value) { nseek(address(), value); return this; }
/** Sets the specified value to the {@link #tell} field. */
public OpusFileCallbacks tell(@Nullable @NativeType("op_tell_func") OPTellFuncI value) { ntell(address(), value); return this; }
/** Sets the specified value to the {@link #close$} field. */
public OpusFileCallbacks close$(@Nullable @NativeType("op_close_func") OPCloseFuncI value) { nclose$(address(), value); return this; }
/** Initializes this struct with the specified values. */
public OpusFileCallbacks set(
OPReadFuncI read,
OPSeekFuncI seek,
OPTellFuncI tell,
OPCloseFuncI close$
) {
read(read);
seek(seek);
tell(tell);
close$(close$);
return this;
}
/**
* Copies the specified struct data to this struct.
*
* @param src the source struct
*
* @return this struct
*/
public OpusFileCallbacks set(OpusFileCallbacks src) {
memCopy(src.address(), address(), SIZEOF);
return this;
}
// -----------------------------------
/** Returns a new {@code OpusFileCallbacks} instance allocated with {@link MemoryUtil#memAlloc memAlloc}. The instance must be explicitly freed. */
public static OpusFileCallbacks malloc() {
return wrap(OpusFileCallbacks.class, nmemAllocChecked(SIZEOF));
}
/** Returns a new {@code OpusFileCallbacks} instance allocated with {@link MemoryUtil#memCalloc memCalloc}. The instance must be explicitly freed. */
public static OpusFileCallbacks calloc() {
return wrap(OpusFileCallbacks.class, nmemCallocChecked(1, SIZEOF));
}
/** Returns a new {@code OpusFileCallbacks} instance allocated with {@link BufferUtils}. */
public static OpusFileCallbacks create() {
ByteBuffer container = BufferUtils.createByteBuffer(SIZEOF);
return wrap(OpusFileCallbacks.class, memAddress(container), container);
}
/** Returns a new {@code OpusFileCallbacks} instance for the specified memory address. */
public static OpusFileCallbacks create(long address) {
return wrap(OpusFileCallbacks.class, address);
}
/** Like {@link #create(long) create}, but returns {@code null} if {@code address} is {@code NULL}. */
@Nullable
public static OpusFileCallbacks createSafe(long address) {
return address == NULL ? null : wrap(OpusFileCallbacks.class, address);
}
/**
* Returns a new {@link OpusFileCallbacks.Buffer} instance allocated with {@link MemoryUtil#memAlloc memAlloc}. The instance must be explicitly freed.
*
* @param capacity the buffer capacity
*/
public static OpusFileCallbacks.Buffer malloc(int capacity) {
return wrap(Buffer.class, nmemAllocChecked(__checkMalloc(capacity, SIZEOF)), capacity);
}
/**
* Returns a new {@link OpusFileCallbacks.Buffer} instance allocated with {@link MemoryUtil#memCalloc memCalloc}. The instance must be explicitly freed.
*
* @param capacity the buffer capacity
*/
public static OpusFileCallbacks.Buffer calloc(int capacity) {
return wrap(Buffer.class, nmemCallocChecked(capacity, SIZEOF), capacity);
}
/**
* Returns a new {@link OpusFileCallbacks.Buffer} instance allocated with {@link BufferUtils}.
*
* @param capacity the buffer capacity
*/
public static OpusFileCallbacks.Buffer create(int capacity) {
ByteBuffer container = __create(capacity, SIZEOF);
return wrap(Buffer.class, memAddress(container), capacity, container);
}
/**
* Create a {@link OpusFileCallbacks.Buffer} instance at the specified memory.
*
* @param address the memory address
* @param capacity the buffer capacity
*/
public static OpusFileCallbacks.Buffer create(long address, int capacity) {
return wrap(Buffer.class, address, capacity);
}
/** Like {@link #create(long, int) create}, but returns {@code null} if {@code address} is {@code NULL}. */
@Nullable
public static OpusFileCallbacks.Buffer createSafe(long address, int capacity) {
return address == NULL ? null : wrap(Buffer.class, address, capacity);
}
/**
* Returns a new {@code OpusFileCallbacks} instance allocated on the specified {@link MemoryStack}.
*
* @param stack the stack from which to allocate
*/
public static OpusFileCallbacks malloc(MemoryStack stack) {
return wrap(OpusFileCallbacks.class, stack.nmalloc(ALIGNOF, SIZEOF));
}
/**
* Returns a new {@code OpusFileCallbacks} instance allocated on the specified {@link MemoryStack} and initializes all its bits to zero.
*
* @param stack the stack from which to allocate
*/
public static OpusFileCallbacks calloc(MemoryStack stack) {
return wrap(OpusFileCallbacks.class, stack.ncalloc(ALIGNOF, 1, SIZEOF));
}
/**
* Returns a new {@link OpusFileCallbacks.Buffer} instance allocated on the specified {@link MemoryStack}.
*
* @param stack the stack from which to allocate
* @param capacity the buffer capacity
*/
public static OpusFileCallbacks.Buffer malloc(int capacity, MemoryStack stack) {
return wrap(Buffer.class, stack.nmalloc(ALIGNOF, capacity * SIZEOF), capacity);
}
/**
* Returns a new {@link OpusFileCallbacks.Buffer} instance allocated on the specified {@link MemoryStack} and initializes all its bits to zero.
*
* @param stack the stack from which to allocate
* @param capacity the buffer capacity
*/
public static OpusFileCallbacks.Buffer calloc(int capacity, MemoryStack stack) {
return wrap(Buffer.class, stack.ncalloc(ALIGNOF, capacity, SIZEOF), capacity);
}
// -----------------------------------
/** Unsafe version of {@link #read}. */
public static OPReadFunc nread(long struct) { return OPReadFunc.create(memGetAddress(struct + OpusFileCallbacks.READ)); }
/** Unsafe version of {@link #seek}. */
@Nullable public static OPSeekFunc nseek(long struct) { return OPSeekFunc.createSafe(memGetAddress(struct + OpusFileCallbacks.SEEK)); }
/** Unsafe version of {@link #tell}. */
@Nullable public static OPTellFunc ntell(long struct) { return OPTellFunc.createSafe(memGetAddress(struct + OpusFileCallbacks.TELL)); }
/** Unsafe version of {@link #close$}. */
@Nullable public static OPCloseFunc nclose$(long struct) { return OPCloseFunc.createSafe(memGetAddress(struct + OpusFileCallbacks.CLOSE)); }
/** Unsafe version of {@link #read(OPReadFuncI) read}. */
public static void nread(long struct, OPReadFuncI value) { memPutAddress(struct + OpusFileCallbacks.READ, value.address()); }
/** Unsafe version of {@link #seek(OPSeekFuncI) seek}. */
public static void nseek(long struct, @Nullable OPSeekFuncI value) { memPutAddress(struct + OpusFileCallbacks.SEEK, memAddressSafe(value)); }
/** Unsafe version of {@link #tell(OPTellFuncI) tell}. */
public static void ntell(long struct, @Nullable OPTellFuncI value) { memPutAddress(struct + OpusFileCallbacks.TELL, memAddressSafe(value)); }
/** Unsafe version of {@link #close$(OPCloseFuncI) close$}. */
public static void nclose$(long struct, @Nullable OPCloseFuncI value) { memPutAddress(struct + OpusFileCallbacks.CLOSE, memAddressSafe(value)); }
/**
* Validates pointer members that should not be {@code NULL}.
*
* @param struct the struct to validate
*/
public static void validate(long struct) {
check(memGetAddress(struct + OpusFileCallbacks.READ));
}
// -----------------------------------
/** An array of {@link OpusFileCallbacks} structs. */
public static class Buffer extends StructBuffer<OpusFileCallbacks, Buffer> implements NativeResource {
private static final OpusFileCallbacks ELEMENT_FACTORY = OpusFileCallbacks.create(-1L);
/**
* Creates a new {@code OpusFileCallbacks.Buffer} instance backed by the specified container.
*
* Changes to the container's content will be visible to the struct buffer instance and vice versa. The two buffers' position, limit, and mark values
* will be independent. The new buffer's position will be zero, its capacity and its limit will be the number of bytes remaining in this buffer divided
* by {@link OpusFileCallbacks#SIZEOF}, and its mark will be undefined.
*
* <p>The created buffer instance holds a strong reference to the container object.</p>
*/
public Buffer(ByteBuffer container) {
super(container, container.remaining() / SIZEOF);
}
public Buffer(long address, int cap) {
super(address, null, -1, 0, cap, cap);
}
Buffer(long address, @Nullable ByteBuffer container, int mark, int pos, int lim, int cap) {
super(address, container, mark, pos, lim, cap);
}
@Override
protected Buffer self() {
return this;
}
@Override
protected OpusFileCallbacks getElementFactory() {
return ELEMENT_FACTORY;
}
/** @return the value of the {@link OpusFileCallbacks#read} field. */
@NativeType("op_read_func")
public OPReadFunc read() { return OpusFileCallbacks.nread(address()); }
/** @return the value of the {@link OpusFileCallbacks#seek} field. */
@Nullable
@NativeType("op_seek_func")
public OPSeekFunc seek() { return OpusFileCallbacks.nseek(address()); }
/** @return the value of the {@link OpusFileCallbacks#tell} field. */
@Nullable
@NativeType("op_tell_func")
public OPTellFunc tell() { return OpusFileCallbacks.ntell(address()); }
/** @return the value of the {@link OpusFileCallbacks#close$} field. */
@Nullable
@NativeType("op_close_func")
public OPCloseFunc close$() { return OpusFileCallbacks.nclose$(address()); }
/** Sets the specified value to the {@link OpusFileCallbacks#read} field. */
public OpusFileCallbacks.Buffer read(@NativeType("op_read_func") OPReadFuncI value) { OpusFileCallbacks.nread(address(), value); return this; }
/** Sets the specified value to the {@link OpusFileCallbacks#seek} field. */
public OpusFileCallbacks.Buffer seek(@Nullable @NativeType("op_seek_func") OPSeekFuncI value) { OpusFileCallbacks.nseek(address(), value); return this; }
/** Sets the specified value to the {@link OpusFileCallbacks#tell} field. */
public OpusFileCallbacks.Buffer tell(@Nullable @NativeType("op_tell_func") OPTellFuncI value) { OpusFileCallbacks.ntell(address(), value); return this; }
/** Sets the specified value to the {@link OpusFileCallbacks#close$} field. */
public OpusFileCallbacks.Buffer close$(@Nullable @NativeType("op_close_func") OPCloseFuncI value) { OpusFileCallbacks.nclose$(address(), value); return this; }
}
} | LWJGL-CI/lwjgl3 | modules/lwjgl/opus/src/generated/java/org/lwjgl/util/opus/OpusFileCallbacks.java | Java | bsd-3-clause | 14,770 | [
30522,
1013,
1008,
1008,
9385,
1048,
2860,
3501,
23296,
1012,
2035,
2916,
9235,
1012,
1008,
6105,
3408,
1024,
16770,
1024,
1013,
1013,
7479,
1012,
1048,
2860,
3501,
23296,
1012,
8917,
1013,
6105,
1008,
3698,
7013,
5371,
1010,
2079,
2025,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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... |
# Cookbook Name:: donar
# Attributes:: default
#
# Copyright 2012, cloudbau GmbH
#
# 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.
#
default['donar']['install_method'] = 'source'
default['donar']['service_type'] = 'passenger' # one of 'passenger' or 'foreman'
default['donar']['fqdn'] = 'bedienfeld.cloudbau.net'
default['donar']['domain'] = 'cloudbau.net'
default['donar']['rails_env'] = 'production'
default['donar']['port'] = '3000'
default['donar']['user'] = 'donar'
default['donar']['group'] = 'donar'
default['donar']['ruby_version'] = "1.9.3-p286"
default['donar']['repository_url'] = "git@github.com:cloudbau/donar.git"
default['donar']['repository_ref'] = "master"
default['donar']['root'] = "/opt/cloudbau/"
default['donar']['home'] = "/home/donar/"
default['donar']['repo_local_uri'] = "/opt/cloudbau/donar"
default['donar']['keystone_server_name'] = "10.124.0.10"
default['donar']['passenger']['version'] = "3.0.19"
default['wodan']['fqdn'] = 'kontrollfeld.cloudbau.net'
default['wodan']['domain'] = 'cloudbau.net'
default['wodan']['rails_env'] = 'production'
default['wodan']['user'] = default['donar']['user']
default['wodan']['port'] = '3333'
default['wodan']['group'] = default['donar']['group']
default['wodan']['ruby_version'] = default['donar']['ruby_version']
default['wodan']['repository_url'] = "git@github.com:cloudbau/wodan.git"
default['wodan']['repository_ref'] = default['donar']['repository_ref']
default['wodan']['root'] = default['donar']['root']
default['wodan']['home'] = default['donar']['home']
default['wodan']['repo_local_uri'] = "/opt/cloudbau/wodan"
default['ssh_known_hosts'] = ["|1|uDf2a0IQwtVLXkkXNFgcM6h4w3I=|owx2vBS4E7YdLN6C1AKLAtld1sQ= ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAq2A7hRGmdnm9tUDbO9IDSwBK6TbQa+PXYPCPy6rbTrTtw7PHkccKrpp0yVhp5HdEIcKr6pLlVDBfOLX9QUsyCOV0wzfjIJNlGEYsdlLJizHhbn2mUjvSAHQqZETYP81eFzLQNnPHt4EVVUh7VfDESU84KezmD5QlWpXLmvU31/yMf+Se8xhHTvKSCZIFImWwoG6mbUoWf9nzpIoaSjB+weqqUUmpaaasXVal72J+UX2B+2RPW3RcT0eOzQgqlJL3RKrTJvdsjE3JEAvGq3lGHSZXy28G3skua2SmVi/w4yCE6gbODqnTWlg7+wC604ydGXA8VJiS5ap43JXiUFFAaQ=="]
default['deploy_key']=nil
| cloudbau/chef-donar | attributes/default.rb | Ruby | agpl-3.0 | 2,607 | [
30522,
1001,
5660,
8654,
2171,
1024,
1024,
24260,
2099,
1001,
12332,
1024,
1024,
12398,
1001,
1001,
9385,
2262,
1010,
6112,
27773,
18289,
1001,
1001,
7000,
2104,
1996,
15895,
6105,
1010,
2544,
1016,
1012,
1014,
1006,
1996,
1000,
6105,
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... |
#ifndef BEARER_TOKEN_H
#define BEARER_TOKEN_H
#include <stdint.h>
#include "json.h"
#include "json_object.h"
#ifdef __cplusplus
extern "C" {
#endif
#define ACCESS_ACTION_NONE 0
#define ACCESS_ACTION_PULL (1<<0)
#define ACCESS_ACTION_PUSH (1<<1)
typedef struct _bearer_token bearer_token_t;
typedef enum jwt_alg {
JWT_ALG_NONE = 0,
JWT_ALG_RS256,
JWT_ALG_HS256
} jwt_alg_t;
int bearer_token_new(bearer_token_t **bearer_token);
int bearer_token_set_alg(bearer_token_t *token, jwt_alg_t alg);
jwt_alg_t brarer_token_get_alg(bearer_token_t *token);
int bearer_token_set_pk_file_name(bearer_token_t *token, const char *pk_name);
int bearer_token_load_pk(bearer_token_t *token);
int bearer_token_init(bearer_token_t *token);
int bearer_token_set_expiration(bearer_token_t *token, int64_t expiration);
int bearer_token_set_iss(bearer_token_t *token, char *iss);
int bearer_token_set_sub(bearer_token_t *token, char *sub);
int bearer_token_set_aud(bearer_token_t *token, char *aud);
int bearer_token_add_access(bearer_token_t *token, char *type, char *name, int actions);
int bearer_token_del_all_access(bearer_token_t *token);
int bearer_token_dump_string(bearer_token_t *token, char **out);
void bearer_token_free(bearer_token_t *token);
#ifdef __cplusplus
}
#endif
#endif /* BEARER_TOKEN_H */
| fovecifer/libBearerToken | bearer_token.h | C | apache-2.0 | 1,342 | [
30522,
1001,
2065,
13629,
2546,
20905,
1035,
19204,
1035,
1044,
1001,
9375,
20905,
1035,
19204,
1035,
1044,
1001,
2421,
1026,
2358,
8718,
2102,
1012,
1044,
1028,
1001,
2421,
1000,
1046,
3385,
1012,
1044,
1000,
1001,
2421,
1000,
1046,
3385,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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... |
#ifndef QGCTABBEDINFOVIEW_H
#define QGCTABBEDINFOVIEW_H
#include <QWidget>
#include "ui_QGCTabbedInfoView.h"
#include "MAVLinkDecoder.h"
#include "QGCMessageView.h"
#include "UASQuickView.h"
#include "UASRawStatusView.h"
class QGCTabbedInfoView : public QWidget
{
Q_OBJECT
public:
explicit QGCTabbedInfoView(QWidget *parent = 0);
~QGCTabbedInfoView();
void addSource(MAVLinkDecoder *decoder);
private:
MAVLinkDecoder *m_decoder;
Ui::QGCTabbedInfoView ui;
QGCMessageView *messageView;
UASQuickView *quickView;
UASRawStatusView *rawView;
};
#endif // QGCTABBEDINFOVIEW_H
| lis-epfl/qgroundcontrol | src/ui/QGCTabbedInfoView.h | C | agpl-3.0 | 612 | [
30522,
1001,
2065,
13629,
2546,
1053,
18195,
2696,
15499,
2378,
14876,
8584,
1035,
1044,
1001,
9375,
1053,
18195,
2696,
15499,
2378,
14876,
8584,
1035,
1044,
1001,
2421,
1026,
1053,
9148,
24291,
1028,
1001,
2421,
1000,
21318,
1035,
1053,
18... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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 "rails_captcha/engine"
require 'rails_captcha/captcha/config'
require 'rails_captcha/captcha/model'
require 'rails_captcha/captcha/action'
require 'rails_captcha/captcha/image'
require 'rails_captcha/captcha/cipher'
require 'rails_captcha/captcha/generator'
| st-granat/rails_captcha | lib/rails_captcha.rb | Ruby | mit | 266 | [
30522,
5478,
1000,
15168,
1035,
14408,
7507,
1013,
3194,
1000,
5478,
1005,
15168,
1035,
14408,
7507,
1013,
14408,
7507,
1013,
9530,
8873,
2290,
1005,
5478,
1005,
15168,
1035,
14408,
7507,
1013,
14408,
7507,
1013,
2944,
1005,
5478,
1005,
151... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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 -*-
require "em-websocket"
require "eventmachine-tail"
module Tailer
# Extends FileTail to push data tailed to an EM::Channel. All open websockets
# subscribe to a channel for the request stack and this pushes the data to
# all of them at once.
class StackTail < EventMachine::FileTail
def initialize(filename, channel, startpos=-1)
super(filename, startpos)
@channel = channel
@buffer = BufferedTokenizer.new
end
# This method is called whenever FileTail receives an inotify event for
# the tailed file. It breaks up the data per line and pushes a line at a
# time. This is to prevent the last javascript line from being broken up
# over 2 pushes thus breaking the eval on the front end.
def receive_data(data)
# replace non UTF-8 characters with ?
data.encode!('UTF-8', invalid: :replace, undef: :replace, replace: '�')
@buffer.extract(data).each do |line|
@channel.push line
end
end
end
# Checks if stack log symlink exists and creates Tailer for it
def self.stack_tail(stack, channel, channel_count)
if Deployinator.get_visible_stacks.include?(stack)
filename = "#{Deployinator::Helpers::RUN_LOG_PATH}current-#{stack}"
start_pos = (channel_count == 0) ? 0 : -1
File.exists?(filename) ? StackTail.new(filename, channel, start_pos) : false
end
end
end
| etsy/deployinator | lib/deployinator/stack-tail.rb | Ruby | mit | 1,403 | [
30522,
1001,
1011,
1008,
1011,
16861,
1024,
21183,
2546,
1011,
1022,
1011,
1008,
1011,
5478,
1000,
7861,
1011,
4773,
6499,
19869,
2102,
1000,
5478,
1000,
2724,
22911,
14014,
1011,
5725,
1000,
11336,
5725,
2121,
1001,
8908,
5371,
14162,
2000... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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 Softlayer
class Generator
class ModuleFile < ClassFile
def initialize(name)
@softlayer_name = name.dup
@name = Converter.module_name(name)
raise Exception.new('Not a SoftLayer module') if DataType.object_type(name) == :class
@autoload = Softlayer::Generator::DataType.autoload_for(@softlayer_name)
end
def generate
content = generate_header
content << generate_autoload
content << generate_footer
end
def generate_header
header = ""
full_name = ""
step = 0
total_steps = @name.split("::").size
@name.split("::").each do |class_name|
# iteration setup
full_name << class_name
step.times { header << " " }
# add to header
object_type = object_type(full_name)
header << object_type + " " + class_name
header << "\n"
# iteration teardown
step = step + 1
full_name << "::"
end
header
end
class Exception < Exception; end
end
end
end
| zertico/softlayer | lib/softlayer/generator/module_file.rb | Ruby | mit | 1,114 | [
30522,
11336,
3730,
24314,
2465,
13103,
2465,
11336,
8873,
2571,
1026,
2465,
8873,
2571,
13366,
3988,
4697,
1006,
2171,
1007,
1030,
3730,
24314,
1035,
2171,
1027,
2171,
1012,
4241,
2361,
1030,
2171,
1027,
10463,
2121,
1012,
11336,
1035,
217... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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... |
# Test Specs
These specs are used to specify tests you can run in apps and libs. These do not exist as distinct documents but as subfields of lib and app specs. They are found under the **test** key.
## How Dusty Runs Tests
To facilitate quick turnaround times with testing, Dusty does the following to run tests:
1. Pull or create the image defined in `image` or `build`
2. Run the `once` script and commit the resulting image locally
3. Use the image from Step 2 as the starting point for all test suite runs
## image
```
image: ubuntu:15.04
```
`image` specifies a Docker image on which to base the container used to create the
intermediate testing image. If the image does not exist locally, Dusty will pull it.
If the `image` is hosted in a private registry which requires authentication,
you can add `image_requires_login: True` to force the user to authenticate
before Dusty attempts to pull down the image.
Either `build` or `image` must be supplied in the test spec. They cannot both be supplied.
## build
```
build: .
```
`build` specifies a directory containing a Dockerfile on the host OS which will be used
to build the intermediate testing image.
This path can be absolute or relative. If it is relative, it is relative to repo directory
on the host OS.
Either `build` or `image` must be supplied in the spec. They cannot both be supplied.
## once
```
once:
- pip install -r test_requirements.txt
```
`once` specifies the commands used in Step 2 of test image creation to create a final
testing image. The resulting image is committed locally and used as the starting point
for test suite runs.
Expensive install steps should go in `once` so that Dusty can cache their results.
## suites
`suites` specifies a list of test suites available for this app or lib. Each suite provides
`name` and `description` keys which are shown when using the `dusty test` command.
Each suite may also contain the following keys:
### services
```
services:
- testMongo
- testRedis
```
`services` provides a list of Dusty services which will be linked to the test container for this
suite. Containers are spun up for each service and linked to the final test container. All containers
for a given test suite are also connected to the same network stack. This allows your testing
container to access ports exposed by any test services through its own `localhost`.
Unlike runtime container dependencies, each test suite gets its own copy of the service containers.
This provides service isolation across multiple apps and test suites.
### command
```
command:
- nosetests
```
`command` defines the script to be run to perform the test for this suite.
Tests can accept arguments at runtime through the `dusty test` command. Arguments are passed through
to the final command specified by the `command` list for the suite.
### default_args
```
default_args: tests/unit
```
`default_args` allows you to specify arguments which are passed to the final command in the
suite's `command` list if no arguments are given at runtime. If the user provides arguments to
the `dusty test` command, the `default_args` are ignored.
In this example, the following Dusty commands would cause the following commands to be run inside
the suite's container:
```
> dusty test my-app suiteName
=> nosetests tests/unit
> dusty test my-app suiteName tests/integration
=> nosetests tests/integration
```
### compose
```
compose:
environment:
APP_ENVIRONMENT: local
MONGO_HOST: persistentMongo
```
Dusty uses Docker Compose to create and manage containers. The `compose` key allows you to
override any of the values passed through to Docker Compose at runtime.
For more information on what you can override through this key, please see
the [Docker Compose specification](https://docs.docker.com/compose/yml/).
| gamechanger/dusty | docs/specs/test-specs.md | Markdown | mit | 3,832 | [
30522,
1001,
3231,
28699,
2015,
2122,
28699,
2015,
2024,
2109,
2000,
20648,
5852,
2017,
2064,
2448,
1999,
18726,
1998,
5622,
5910,
1012,
2122,
2079,
2025,
4839,
2004,
5664,
5491,
2021,
2004,
4942,
15155,
1997,
5622,
2497,
1998,
10439,
28699... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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 outbound_test
import (
"context"
"testing"
"v2ray.com/core"
"v2ray.com/core/app/policy"
. "v2ray.com/core/app/proxyman/outbound"
"v2ray.com/core/app/stats"
"v2ray.com/core/common/net"
"v2ray.com/core/common/serial"
"v2ray.com/core/features/outbound"
"v2ray.com/core/proxy/freedom"
"v2ray.com/core/transport/internet"
)
func TestInterfaces(t *testing.T) {
_ = (outbound.Handler)(new(Handler))
_ = (outbound.Manager)(new(Manager))
}
const v2rayKey core.V2rayKey = 1
func TestOutboundWithoutStatCounter(t *testing.T) {
config := &core.Config{
App: []*serial.TypedMessage{
serial.ToTypedMessage(&stats.Config{}),
serial.ToTypedMessage(&policy.Config{
System: &policy.SystemPolicy{
Stats: &policy.SystemPolicy_Stats{
InboundUplink: true,
},
},
}),
},
}
v, _ := core.New(config)
v.AddFeature((outbound.Manager)(new(Manager)))
ctx := context.WithValue(context.Background(), v2rayKey, v)
h, _ := NewHandler(ctx, &core.OutboundHandlerConfig{
Tag: "tag",
ProxySettings: serial.ToTypedMessage(&freedom.Config{}),
})
conn, _ := h.(*Handler).Dial(ctx, net.TCPDestination(net.DomainAddress("localhost"), 13146))
_, ok := conn.(*internet.StatCouterConnection)
if ok {
t.Errorf("Expected conn to not be StatCouterConnection")
}
}
func TestOutboundWithStatCounter(t *testing.T) {
config := &core.Config{
App: []*serial.TypedMessage{
serial.ToTypedMessage(&stats.Config{}),
serial.ToTypedMessage(&policy.Config{
System: &policy.SystemPolicy{
Stats: &policy.SystemPolicy_Stats{
OutboundUplink: true,
OutboundDownlink: true,
},
},
}),
},
}
v, _ := core.New(config)
v.AddFeature((outbound.Manager)(new(Manager)))
ctx := context.WithValue(context.Background(), v2rayKey, v)
h, _ := NewHandler(ctx, &core.OutboundHandlerConfig{
Tag: "tag",
ProxySettings: serial.ToTypedMessage(&freedom.Config{}),
})
conn, _ := h.(*Handler).Dial(ctx, net.TCPDestination(net.DomainAddress("localhost"), 13146))
_, ok := conn.(*internet.StatCouterConnection)
if !ok {
t.Errorf("Expected conn to be StatCouterConnection")
}
}
| panzer13/v2ray-core | app/proxyman/outbound/handler_test.go | GO | mit | 2,146 | [
30522,
7427,
2041,
15494,
1035,
3231,
12324,
1006,
1000,
6123,
1000,
1000,
5604,
1000,
30524,
2386,
1013,
2041,
15494,
1000,
1000,
1058,
2475,
9447,
1012,
4012,
1013,
4563,
1013,
10439,
1013,
26319,
1000,
1000,
1058,
2475,
9447,
1012,
4012,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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 -*-
##############################################################################
#
# Ingenieria ADHOC - ADHOC SA
# https://launchpad.net/~ingenieria-adhoc
#
# This program 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.
#
# 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 Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
import waybill
import wizard
import travel
import vehicle
import requirement
import res_partner
import waybill_expense
import account_invoice
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
| adhoc-dev/odoo-logistic | addons/logistic_x/__init__.py | Python | agpl-3.0 | 1,161 | [
30522,
1001,
1011,
1008,
1011,
16861,
1024,
21183,
2546,
1011,
1022,
1011,
1008,
30524,
1001,
1001,
1001,
1001,
1001,
1001,
1001,
1001,
1001,
1001,
1001,
1001,
1001,
1001,
1001,
1001,
1001,
1001,
1001,
1001,
1001,
1001,
1001,
1001,
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... |
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
namespace Fungus
{
[CommandInfo("Flow",
"If",
"If the test expression is true, execute the following command block.")]
[AddComponentMenu("")]
public class If : Condition
{
[Tooltip("Variable to use in expression")]
[VariableProperty(typeof(BooleanVariable),
typeof(IntegerVariable),
typeof(FloatVariable),
typeof(StringVariable))]
public Variable variable;
[Tooltip("Boolean value to compare against")]
public BooleanData booleanData;
[Tooltip("Integer value to compare against")]
public IntegerData integerData;
[Tooltip("Float value to compare against")]
public FloatData floatData;
[Tooltip("String value to compare against")]
public StringData stringData;
public override void OnEnter()
{
if (parentBlock == null)
{
return;
}
if (variable == null)
{
Continue();
return;
}
EvaluateAndContinue();
}
public bool EvaluateCondition()
{
BooleanVariable booleanVariable = variable as BooleanVariable;
IntegerVariable integerVariable = variable as IntegerVariable;
FloatVariable floatVariable = variable as FloatVariable;
StringVariable stringVariable = variable as StringVariable;
bool condition = false;
if (booleanVariable != null)
{
condition = booleanVariable.Evaluate(compareOperator, booleanData.Value);
}
else if (integerVariable != null)
{
condition = integerVariable.Evaluate(compareOperator, integerData.Value);
}
else if (floatVariable != null)
{
condition = floatVariable.Evaluate(compareOperator, floatData.Value);
}
else if (stringVariable != null)
{
condition = stringVariable.Evaluate(compareOperator, stringData.Value);
}
return condition;
}
protected void EvaluateAndContinue()
{
if (EvaluateCondition())
{
OnTrue();
}
else
{
OnFalse();
}
}
protected virtual void OnTrue()
{
Continue();
}
protected virtual void OnFalse()
{
// Last command in block
if (commandIndex >= parentBlock.commandList.Count)
{
Stop();
return;
}
// Find the next Else, ElseIf or End command at the same indent level as this If command
for (int i = commandIndex + 1; i < parentBlock.commandList.Count; ++i)
{
Command nextCommand = parentBlock.commandList[i];
if (nextCommand == null)
{
continue;
}
// Find next command at same indent level as this If command
// Skip disabled commands, comments & labels
if (!nextCommand.enabled ||
nextCommand.GetType() == typeof(Comment) ||
nextCommand.GetType() == typeof(Label) ||
nextCommand.indentLevel != indentLevel)
{
continue;
}
System.Type type = nextCommand.GetType();
if (type == typeof(Else) ||
type == typeof(End))
{
if (i >= parentBlock.commandList.Count - 1)
{
// Last command in Block, so stop
Stop();
}
else
{
// Execute command immediately after the Else or End command
Continue(nextCommand.commandIndex + 1);
return;
}
}
else if (type == typeof(ElseIf))
{
// Execute the Else If command
Continue(i);
return;
}
}
// No matching End command found, so just stop the block
Stop();
}
public override string GetSummary()
{
if (variable == null)
{
return "Error: No variable selected";
}
string summary = variable.key + " ";
summary += Condition.GetOperatorDescription(compareOperator) + " ";
if (variable.GetType() == typeof(BooleanVariable))
{
summary += booleanData.GetDescription();
}
else if (variable.GetType() == typeof(IntegerVariable))
{
summary += integerData.GetDescription();
}
else if (variable.GetType() == typeof(FloatVariable))
{
summary += floatData.GetDescription();
}
else if (variable.GetType() == typeof(StringVariable))
{
summary += stringData.GetDescription();
}
return summary;
}
public override bool HasReference(Variable variable)
{
return (variable == this.variable);
}
public override bool OpenBlock()
{
return true;
}
public override Color GetButtonColor()
{
return new Color32(253, 253, 150, 255);
}
}
} | RonanPearce/Fungus | Assets/Fungus/Flowchart/Scripts/Commands/If.cs | C# | mit | 4,397 | [
30522,
2478,
8499,
13159,
3170,
1025,
2478,
2291,
1012,
6407,
1025,
2478,
2291,
1012,
6407,
1012,
12391,
1025,
3415,
15327,
16622,
1063,
1031,
3094,
2378,
14876,
1006,
1000,
4834,
1000,
1010,
1000,
2065,
1000,
1010,
1000,
2065,
1996,
3231,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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 me.rbrickis.mojo.utils;
public final class PrimitiveUtils {
public static Object toPrimitiveNumber(Number number) {
if (number instanceof Byte) {
return number.byteValue();
} else if (number instanceof Long) {
return number.longValue();
} else if (number instanceof Short) {
return number.shortValue();
} else if (number instanceof Integer) {
return number.intValue();
} else if (number instanceof Float) {
return number.floatValue();
} else if (number instanceof Double) {
return number.doubleValue();
}
return 0;
}
public static Object toPrimitiveBoolean(Boolean booleans) {
return booleans.booleanValue();
}
}
| rbrick/Mojo | Core/src/main/java/me/rbrickis/mojo/utils/PrimitiveUtils.java | Java | mit | 784 | [
30522,
7427,
2033,
1012,
21144,
11285,
2483,
1012,
28017,
1012,
21183,
12146,
1025,
2270,
2345,
2465,
10968,
21823,
4877,
1063,
2270,
10763,
4874,
2327,
20026,
13043,
19172,
5677,
1006,
2193,
2193,
1007,
1063,
2065,
1006,
2193,
6013,
11253,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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 In.entity
class RelationHistory(In.entity.Entity):
'''RelationHistory Entity class.
'''
def __init__(self, data = None, items = None, **args):
# default
self.relation_id = 0
self.action = ''
self.actor_entity_type = ''
self.actor_entity_id = 0
self.message = ''
super().__init__(data, items, **args)
@IN.register('RelationHistory', type = 'Entitier')
class RelationHistoryEntitier(In.entity.EntityEntitier):
'''Base RelationHistory Entitier'''
# RelationHistory needs entity insert/update/delete hooks
invoke_entity_hook = False
# load all is very heavy
entity_load_all = False
@IN.register('RelationHistory', type = 'Model')
class RelationHistoryModel(In.entity.EntityModel):
'''RelationHistory Model'''
@IN.hook
def entity_model():
return {
'RelationHistory' : { # entity name
'table' : { # table
'name' : 'relation_history',
'columns' : { # table columns / entity attributes
'id' : {},
'type' : {},
'created' : {},
'status' : {},
'nabar_id' : {},
'relation_id' : {
'type' : 'int', 'unsigned' : True, 'not null' : True,
'description' : 'RelationHistory Id',
},
'actor_entity_type' : {
'type' : 'varchar', 'length' : 32, 'not null' : True,
},
'actor_entity_id' : {
'type' : 'varchar', 'int' : 32, 'not null' : True, 'default' : 'nabar',
},
'message' : {
'type' : 'varchar', 'length' : 32, 'not null' : True,
},
},
'keys' : {
'primary' : 'id',
},
},
},
}
@IN.register('RelationHistory', type = 'Themer')
class RelationHistoryThemer(In.entity.EntityThemer):
'''RelationHistory themer'''
| vinoth3v/In_addon_relation | relation/entity_relation_history.py | Python | apache-2.0 | 1,675 | [
30522,
1001,
12324,
1999,
1012,
9178,
2465,
7189,
24158,
7062,
1006,
1999,
1012,
9178,
1012,
9178,
1007,
1024,
1005,
1005,
1005,
7189,
24158,
7062,
9178,
2465,
1012,
1005,
1005,
1005,
13366,
1035,
1035,
1999,
4183,
1035,
1035,
1006,
2969,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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... |
class Chakra < Formula
desc "The core part of the JavaScript engine that powers Microsoft Edge"
homepage "https://github.com/Microsoft/ChakraCore"
url "https://github.com/Microsoft/ChakraCore/archive/v1.7.3.tar.gz"
sha256 "1d521d43ad0afd5dbb089829cba1e82c0fb8c17c26f4ff21d7be4ab6825ac4eb"
bottle do
cellar :any
sha256 "5010ade4fed3ead0ceb5ccbfa053c84df0893ed0fc0fea400feab9504813a3f5" => :high_sierra
sha256 "70a9692d9b9fafd0f38403a1cb174d933cb22e3676bde099da08ccde30e8b4db" => :sierra
sha256 "a4bc47700b7c867e8cf67a64704695e1a16e0fa4286bf2c38f3576d9d8d03f46" => :el_capitan
end
depends_on "cmake" => :build
depends_on "icu4c"
def install
system "./build.sh", "--lto-thin", "--static", "--icu=#{Formula["icu4c"].opt_include}", "-j=#{ENV.make_jobs}", "-y"
bin.install "out/Release/ch" => "chakra"
end
test do
(testpath/"test.js").write("print('Hello world!');\n")
assert_equal "Hello world!", shell_output("#{bin}/chakra test.js").chomp
end
end
| grhawk/homebrew-core | Formula/chakra.rb | Ruby | bsd-2-clause | 1,004 | [
30522,
2465,
15775,
22272,
1026,
5675,
4078,
2278,
1000,
1996,
4563,
2112,
1997,
1996,
9262,
22483,
3194,
2008,
4204,
7513,
3341,
1000,
2188,
13704,
1000,
16770,
1024,
1013,
1013,
21025,
2705,
12083,
1012,
4012,
1013,
7513,
1013,
15775,
222... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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... |
# javaorjavascript
| ChrisMissal/javaorjavascript | README.md | Markdown | mit | 19 | [
30522,
1001,
9262,
2953,
3900,
12044,
23235,
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,
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) 2004,University of Illinois at Urbana-Champaign. All rights reserved.
*
* Created on Jun 14, 2006
*
* Developed by: CCT, Center for Computation and Technology,
* NCSA, University of Illinois at Urbana-Champaign
* OSC, Ohio Supercomputing Center
* TACC, Texas Advanced Computing Center
* UKy, University of Kentucky
*
* https://www.gridchem.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 with 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:
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimers.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimers in the documentation
* and/or other materials provided with the distribution.
* 3. Neither the names of Chemistry and Computational Biology Group , NCSA,
* University of Illinois at Urbana-Champaign, nor the names of its contributors
* may be used to endorse or promote products derived from this Software without
* specific prior written permission.
*
* 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 CONTRIBUTORS 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 WITH THE SOFTWARE.
*/
package org.gridchem.client.gui.filebrowser;
import java.net.URI;
/**
* Interface for the <code>FileBrowser</code> class to provide some common
* methods. This is probably unnecessary.
*
* @author Rion Dooley < dooley [at] tacc [dot] utexas [dot] edu >
*
*/
public interface FileBrowser {
/**
* Set the path of the file browser
* @param uri
*/
public void setPath(String path);
/**
* Get the currently selected files URI
*/
public String getPath();
/**
* Select the file corresponding to the file name
*
* @param filename
*/
public void setSelected(String filename);
/**
* Get the name of the currently selected file
*
*/
public String getSelected();
}
| SciGaP/SEAGrid-Desktop-GUI | src/main/java/org/gridchem/client/gui/filebrowser/FileBrowser.java | Java | apache-2.0 | 2,787 | [
30522,
1013,
1008,
9385,
1006,
1039,
1007,
2432,
1010,
2118,
1997,
4307,
2012,
27929,
1011,
28843,
1012,
2035,
2916,
9235,
1012,
1008,
1008,
2580,
2006,
12022,
2403,
1010,
2294,
1008,
1008,
2764,
2011,
1024,
10507,
2102,
1010,
2415,
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... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.