text
stringlengths
201
300k
source_other
stringlengths
180
1.21k
<reponame>bopopescu/BEMOSSx import logging import sys from volttron.platform.agent import BaseAgent, PublishMixin, periodic from volttron.platform.agent import utils, matching from volttron.platform.messaging import headers as headers_mod, topics utils.setup_logging() _log = logging.getLogger(__name__) class TestRegistrationAgent(PublishMixin, BaseAgent): def __init__(self, config_path, **kwargs): super(TestRegistrationAgent, self).__init__(**kwargs) self.config = utils.load_config(config_path) def setup(self): self._agent_id = self.config['agentid'] super(TestRegistrationAgent, self).setup() self.run_tests() def run_tests(self): _log.debug("Attempting to register devices") self.post_register_test() _log.debug("Attempting to list registered devices") self.post_list_registered_test() _log.debug("Attempting to unregister devices") self.post_unregister_test() _log.debug("Attempting to list registered devices") self.post_list_registered_test() _log.debug("Attempting to see if individual devices are registered") self.post_is_registered_test() def post_register_test(self): headers = {'requesterID' : self._agent_id, "From" : "RegistrationAgentTester"} msg = {"agents_to_register" : {"agent_1" : "agent_1 info", "agent_2" : "agent_2_info"} } self.publish_json("registration/register", headers, msg) @matching.match_exact("registration/register/response") def on_test_register_response(self, topic, headers, message, match): try: print "Received registration response.\nMessage: {msg}".format(msg = message) except: print "FAILURE due to exception: %s" % sys.exc_info()[0] def post_unregister_test(self): headers = {'requesterID' : self._agent_id, "From" : "RegistrationAgentTester"} msg = {"agents_to_unregister" : ["agent_1", "agent_3"]} self.publish_json("registration/unregister", headers, msg) @matching.match_exact("registration/unregister/response") def on_test_unregister_response(self, topic, headers, message, match): try: print "Received unregistration response.\nMessage: {msg}".format(msg = message) except: print "FAILURE due to exception: %s" % sys.exc_info()[0] def post_list_registered_test(self): headers = {'requesterID' : self._agent_id, "From" : "RegistrationAgentTester"} msg = {} self.publish_json("registration/list", headers, msg) @matching.match_exact("registration/list/response") def on_test_list_registered_response(self, topic, headers, message, match): try: print "Received list_registered response.\nMessage: {msg}".format(msg = message) except: print "FAILURE due to exception: %s" % sys.exc_info()[0] def post_is_registered_test(self): headers = {'requesterID' : self._agent_id, "From" : "RegistrationAgentTester"} msg = {"agents" : ["agent_1"]} self.publish_json("registration/is_registered", headers, msg) msg = {"agents" : ["agent_2"]} self.publish_json("registration/is_registered", headers, msg) msg = {"agents" : ["agent_3"]} self.publish_json("registration/is_registered", headers, msg) msg = {"agents" : ["agent_1", "agent_2", "agent_3"]} self.publish_json("registration/is_registered", headers, msg) @matching.match_exact("registration/is_registered/response") def on_test_is_registered_response(self, topic, headers, message, match): try: print "Received is_registered response.\nMessage: {msg}".format(msg = message) except: print "FAILURE due to exception: %s" % sys.exc_info()[0] def main(argv=sys.argv): '''Main method called by the eggsecutable.''' utils.default_main(TestRegistrationAgent, description='Testing agent for Archiver Agent in VOLTTRON Lite', argv=argv) if __name__ == '__main__': # Entry point for script try: sys.exit(main()) except KeyboardInterrupt: pass
{'dir': 'python', 'id': '624343', 'max_stars_count': '0', 'max_stars_repo_name': 'bopopescu/BEMOSSx', 'max_stars_repo_path': 'Agents/TestRegistrationAgent/testregistrationAgent/agent.py', 'n_tokens_mistral': 1293, 'n_tokens_neox': 1248, 'n_words': 270}
using System; using Eklee.Azure.Functions.GraphQl.Repository.DocumentDb; using Eklee.Azure.Functions.GraphQl.Repository.Http; using Eklee.Azure.Functions.GraphQl.Repository.InMemory; namespace Eklee.Azure.Functions.GraphQl { public interface IModelConventionInputBuilder<TSource> where TSource : class { InMemoryConfiguration<TSource> ConfigureInMemory<TType>(); HttpConfiguration<TSource> ConfigureHttp<TType>(); DocumentDbConfiguration<TSource> ConfigureDocumentDb<TType>(); ModelConventionInputBuilder<TSource> Delete<TDeleteInput, TDeleteOutput>( Func<TDeleteInput, TSource> mapDelete, Func<TSource, TDeleteOutput> transform); ModelConventionInputBuilder<TSource> DeleteAll<TDeleteOutput>(Func<TDeleteOutput> getOutput); void Build(); } }
{'dir': 'c-sharp', 'id': '7138376', 'max_stars_count': '67', 'max_stars_repo_name': 'seekdavidlee/Eklee-Azure-Functions-GraphQl', 'max_stars_repo_path': 'Eklee.Azure.Functions.GraphQl/IModelConventionInputBuilder.cs', 'n_tokens_mistral': 243, 'n_tokens_neox': 228, 'n_words': 36}
import socket if "__main__" == __name__: try: sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM); print("create socket succ!"); sock.bind(('127.0.0.1', 6010)); print("bind socket succ!"); sock.listen(5); print("listen succ!"); except: print("init socket err!"); while True: print("listen for client..."); conn, addr = sock.accept(); print("get client"); print(addr); conn.settimeout(5); szBuf = conn.recv(1024); print("recv:" + szBuf); if "0" == szBuf: conn.send('exit'); else: conn.send('welcome client!'); conn.close(); print("end of sevice");
{'dir': 'python', 'id': '9241120', 'max_stars_count': '0', 'max_stars_repo_name': 'mabotech/mabo.io', 'max_stars_repo_path': 'py/AK/test/ak_server2.py', 'n_tokens_mistral': 242, 'n_tokens_neox': 227, 'n_words': 51}
import ControlScheme from "src/components/player/ControlScheme"; const Player = "Player"; Crafty.c(Player, { init() { this.reset(); }, reset() { if (this.has(ControlScheme)) { this.removeComponent(ControlScheme); } } }); export default Player;
{'dir': 'javascript', 'id': '177390', 'max_stars_count': '19', 'max_stars_repo_name': 'speedlazer/game-play', 'max_stars_repo_path': 'src/components/player/Player.js', 'n_tokens_mistral': 91, 'n_tokens_neox': 88, 'n_words': 17}
<gh_stars>0 import unittest import numpy as np from graphz.dataset import GraphDataset class TestCreation(unittest.TestCase): def setUp(self): # This is NOT symmetric. self.sample_A = np.matrix([ [1.0, 0.1, 0.0, 0.3], [0.7, 0.0, 0.0, 0.4], [0.0, 0.0, 0.0, 0.9], [0.5, 0.6, 0.8, 0.0] ]) def test_from_simple_edge_list(self): edges = [(0, 0), (0, 1), (0, 2), (0, 3), (3, 4)] g = GraphDataset.from_edges(n_nodes=5, edges=edges, name='GraphX') self.assertEqual(g.name, 'GraphX') self.assertFalse(g.weighted) self.assertFalse(g.directed) self.assertEqual(g.n_nodes, 5) self.assertEqual(g.n_edges, 5) self.assertSetEqual(set(g.get_edge_iter()), set(map(lambda e : (e[0], e[1], 1), edges))) def test_from_adj_mat_dense_undirected_unweighted(self): node_attrs = ['a', 'b', 'c', 'd'] node_labels = [1, 2, 4, 5] edges_expected = [(0, 0, 1), (0, 1, 1), (0, 3, 1), (1, 3, 1), (2, 3, 1)] g = GraphDataset.from_adj_mat(self.sample_A, directed=False, weighted=False, name='Unweighted', node_attributes=node_attrs, node_labels=node_labels) self.assertEqual(g.name, 'Unweighted') self.assertSetEqual(set(g.get_edge_iter()), set(edges_expected)) self.assertListEqual(list(g.node_attributes), node_attrs) self.assertListEqual(list(g.node_labels), node_labels) def test_from_adj_mat_dense_undirected_weighted(self): edges_expected = [(0, 0, 1.0), (0, 1, 0.1), (0, 3, 0.3), (1, 3, 0.4), (2, 3, 0.9)] g = GraphDataset.from_adj_mat(self.sample_A, directed=False, weighted=True, name='Weighted') self.assertEqual(g.name, 'Weighted') self.assertSetEqual(set(g.get_edge_iter()), set(edges_expected)) def test_from_adj_mat_dense_directed_unweighted(self): edges_expected = [(0, 0, 1), (0, 1, 1), (0, 3, 1), (1, 3, 1), (2, 3, 1), (1, 0, 1), (3, 0, 1), (3, 1, 1), (3, 2, 1)] g = GraphDataset.from_adj_mat(self.sample_A, directed=True, weighted=False, name='Unweighted') self.assertEqual(g.name, 'Unweighted') self.assertSetEqual(set(g.get_edge_iter()), set(edges_expected)) def test_from_adj_mat_dense_directed_weighted(self): edges_expected = [(0, 0, 1.0), (0, 1, 0.1), (0, 3, 0.3), (1, 3, 0.4), (2, 3, 0.9), (1, 0, 0.7), (3, 0, 0.5), (3, 1, 0.6), (3, 2, 0.8)] g = GraphDataset.from_adj_mat(self.sample_A, directed=True, weighted=True, name='Weighted') self.assertEqual(g.name, 'Weighted') self.assertSetEqual(set(g.get_edge_iter()), set(edges_expected)) class TestViews(unittest.TestCase): def setUp(self): edges = [(0, 1), (0, 2), (1, 1), (1, 2), (1, 3)] self.g_undirected = GraphDataset.from_edges(n_nodes=5, edges=edges) self.g_directed = GraphDataset.from_edges(n_nodes=5, edges=edges, directed=True) def test_deg_list(self): self.assertListEqual(list(self.g_undirected.deg_list), [2, 4, 2, 1, 0]) # Out degree self.assertListEqual(list(self.g_directed.deg_list), [2, 3, 0, 0, 0]) def test_adj_list(self): self.assertSetEqual(set(self.g_undirected.adj_list[1].keys()), {0, 1, 2, 3}) self.assertSetEqual(set(self.g_undirected.adj_list[2].keys()), {0, 1}) self.assertSetEqual(set(self.g_directed.adj_list[0].keys()), {1, 2}) self.assertEqual(len(self.g_directed.adj_list[2]), 0) class TestAdjacencyMatrix(unittest.TestCase): def test_undirected(self): edges = [(0, 1, 0.1), (1, 2, 0.2), (2, 3, 0.3)] g = GraphDataset.from_edges(n_nodes=4, edges=edges, weighted=True) A = g.get_adj_matrix() A_expected = np.array([ [0.0, 0.1, 0.0, 0.0], [0.1, 0.0, 0.2, 0.0], [0.0, 0.2, 0.0, 0.3], [0.0, 0.0, 0.3, 0.0] ]) self.assertTrue(np.array_equal(A, A_expected)) def test_directed(self): edges = [(0, 1, 0.1), (1, 2, 0.2), (3, 3, 0.5)] g = GraphDataset.from_edges(n_nodes=4, edges=edges, weighted=True, directed=True) A = g.get_adj_matrix() A_expected = np.array([ [0.0, 0.1, 0.0, 0.0], [0.0, 0.0, 0.2, 0.0], [0.0, 0.0, 0.0, 0.0], [0.0, 0.0, 0.0, 0.5] ]) self.assertTrue(np.array_equal(A, A_expected)) class TestLaplacianMatrix(unittest.TestCase): def setUp(self): edges = [(0, 1, 2.0), (0, 2, 1.5), (1, 2, 0.4), (1, 3, 0.2)] self.g_weighted = GraphDataset.from_edges(n_nodes=4, edges=edges, weighted=True) self.g_unweighted = GraphDataset.from_edges(n_nodes=4, edges=edges) def test_unweighted(self): L = self.g_unweighted.get_laplacian() L_sparse = self.g_unweighted.get_laplacian(sparse=True).todense() L_expected = np.array([ [ 2.0, -1.0, -1.0, 0.0], [-1.0, 3.0, -1.0, -1.0], [-1.0, -1.0, 2.0, 0.0], [ 0.0, -1.0, 0.0, 1.0] ]) self.assertTrue(np.array_equal(L, L_expected)) self.assertTrue(np.array_equal(L, L_sparse)) def test_unweighted_normalized(self): Ln = self.g_unweighted.get_laplacian(normalize=True) Ln_sparse = self.g_unweighted.get_laplacian(normalize=True, sparse=True).todense() Ln_expected = np.array([ [ 1. , -0.40824829, -0.5 , 0. ], [-0.40824829, 1. , -0.40824829, -0.57735027], [-0.5 , -0.40824829, 1. , 0. ], [ 0. , -0.57735027, 0. , 1. ] ]) self.assertTrue(np.allclose(Ln, Ln_expected)) self.assertTrue(np.allclose(Ln, Ln_sparse)) def test_weighted(self): L = self.g_weighted.get_laplacian() L_sparse = self.g_weighted.get_laplacian(sparse=True).todense() L_expected = np.array([ [ 3.5, -2.0, -1.5, 0.0], [-2.0, 2.6, -0.4, -0.2], [-1.5, -0.4, 1.9, 0.0], [ 0.0, -0.2, 0.0, 0.2] ]) self.assertTrue(np.array_equal(L, L_expected)) self.assertTrue(np.array_equal(L, L_sparse)) class TestSubgraph(unittest.TestCase): def setUp(self): # A loop graph edges = [(0, 1, 0.1, 'a'), (1, 2, 0.2, 'b'), (2, 3, 0.3, 'c'), (3, 4, 0.4, 'd'), (4, 5, 0.5, 'e'), (5, 0, 0.6, 'f')] node_labels = [11, 22, 33, 44, 55, 66] node_attributes = ['n1', 'n2', 'n3', 'n4', 'n5', 'n6'] self.g_loop = GraphDataset.from_edges(n_nodes=6, edges=edges, weighted=True, directed=False, has_edge_data=True, node_labels=node_labels, node_attributes=node_attributes) def test_edge_removal(self): edges_to_remove = [(0, 1), (0, 2), (4, 3), (1, 0)] sg = self.g_loop.subgraph(edges_to_remove=edges_to_remove) expected_edges = [(1, 2, 0.2, 'b'), (2, 3, 0.3, 'c'), (4, 5, 0.5, 'e'), (0, 5, 0.6, 'f')] self.assertSetEqual(set(sg.get_edge_iter(data=True)), set(expected_edges)) self.assertListEqual(list(sg.deg_list), [1, 1, 2, 1, 1, 2]) def test_node_removal(self): nodes_to_remove = [1, 4, 2, 3] sg = self.g_loop.subgraph(nodes_to_remove=nodes_to_remove) expected_edges = [(0, 1, 0.6, 'f')] self.assertSetEqual(set(sg.get_edge_iter(data=True)), set(expected_edges)) expected_node_data = [(11, 'n1'), (66, 'n6')] self.assertSetEqual(set(zip(sg.node_labels, sg.node_attributes)), set(expected_node_data)) self.assertListEqual(list(sg.deg_list), [1, 1]) def test_node_keeping(self): nodes_to_keep = [2, 1] sg = self.g_loop.subgraph(nodes_to_keep=nodes_to_keep) expected_edges = [(0, 1, 0.2, 'b')] self.assertSetEqual(set(sg.get_edge_iter(data=True)), set(expected_edges)) expected_node_data = [(22, 'n2'), (33, 'n3')] self.assertSetEqual(set(zip(sg.node_labels, sg.node_attributes)), set(expected_node_data)) self.assertListEqual(list(sg.deg_list), [1, 1]) def test_node_plus_edge_removal(self): nodes_to_remove = [0, 2] edges_to_remove = [(1, 0), (2, 3), (4, 5), (5, 0), (3, 4), (0, 1)] sg = self.g_loop.subgraph(nodes_to_remove=nodes_to_remove, edges_to_remove=edges_to_remove) self.assertEqual(sg.n_edges, 0) expected_node_data = [(22, 'n2'), (44, 'n4'), (55, 'n5'), (66, 'n6')] self.assertSetEqual(set(zip(sg.node_labels, sg.node_attributes)), set(expected_node_data)) self.assertListEqual(list(sg.deg_list), [0, 0, 0, 0]) if __name__ == '__main__': unittest.main()
{'dir': 'python', 'id': '2534506', 'max_stars_count': '0', 'max_stars_repo_name': 'morriswmz/graphz', 'max_stars_repo_path': 'graphz/tests/test_graph_dataset.py', 'n_tokens_mistral': 3772, 'n_tokens_neox': 3438, 'n_words': 647}
<gh_stars>0 --- layout: post title: Do not leave any question date: 2007-09-10 11:00:49.000000000 +09:30 type: post published: true status: publish categories: - Thinking tags: [thinking] meta: posturl_add_url: 'yes' _edit_last: '1' views: '825' --- <h1></h1> <div>Remeber: do not leave any question which confuse you, or else you will be lost more when you met it again.</div>
{'dir': 'html', 'id': '434528', 'max_stars_count': '0', 'max_stars_repo_name': 'dbaeyes/dbaeyes.github.io', 'max_stars_repo_path': '_posts/2007-09-10-do-not-leave-any-question.html', 'n_tokens_mistral': 165, 'n_tokens_neox': 139, 'n_words': 52}
package lk.ijse.dep.pos.dao.custom.impl; import lk.ijse.dep.pos.dao.custom.QueryDAO; import lk.ijse.dep.pos.entity.CustomEntity; import org.springframework.stereotype.Repository; import javax.persistence.EntityManager; import javax.persistence.PersistenceContext; import java.sql.Date; import java.util.ArrayList; import java.util.List; @Repository public class QueryDAOImpl implements QueryDAO { @PersistenceContext private EntityManager entityManager; @Override public CustomEntity getOrderInfo(int orderId) throws Exception { return null; } @Override public List<CustomEntity> getOrdersInfo(String query) throws Exception { List<Object[]> resultList = entityManager.createNativeQuery( "SELECT o.id, c.cusId , c.name, o.date, od.qty * od.unit_price FROM Customer c " + "JOIN `order` o ON c.cusId=o.customer_Id " + "JOIN orderdetail od on o.id = od.order_id " + "WHERE o.id LIKE ?1 OR " + "c.cusId LIKE ?1 OR " + "c.name LIKE ?1 OR " + "o.date LIKE ?1 GROUP BY o.id" ).setParameter(1, query).getResultList(); ArrayList<CustomEntity> list = new ArrayList<>(); for (Object[] clo : resultList) { list.add(new CustomEntity((int) clo[0], (String) clo[1], (String) clo[2], (Date) clo[3], (Double) clo[4])); } return list; } }
{'dir': 'java', 'id': '13338155', 'max_stars_count': '0', 'max_stars_repo_name': 'rivinduchamath/POS-Spring-JPA', 'max_stars_repo_path': 'src/lk/ijse/dep/pos/dao/custom/impl/QueryDAOImpl.java', 'n_tokens_mistral': 462, 'n_tokens_neox': 441, 'n_words': 110}
#ifndef CLM_H #define CLM_H #define MUS_VERSION 5 #define MUS_REVISION 14 #define MUS_DATE "19-Apr-13" /* isn't mus_env_interp backwards? */ #include "sndlib.h" #ifndef _MSC_VER #include <sys/param.h> #endif #if HAVE_COMPLEX_TRIG #include <complex.h> #endif #if(!defined(M_PI)) #define M_PI 3.14159265358979323846264338327 #define M_PI_2 (M_PI / 2.0) #endif #define MUS_DEFAULT_SAMPLING_RATE 44100.0 #define MUS_DEFAULT_FILE_BUFFER_SIZE 8192 #define MUS_DEFAULT_ARRAY_PRINT_LENGTH 8 typedef enum {MUS_NOT_SPECIAL, MUS_SIMPLE_FILTER, MUS_FULL_FILTER, MUS_OUTPUT, MUS_INPUT, MUS_DELAY_LINE} mus_clm_extended_t; typedef struct mus_any_class mus_any_class; typedef struct { struct mus_any_class *core; } mus_any; typedef enum {MUS_INTERP_NONE, MUS_INTERP_LINEAR, MUS_INTERP_SINUSOIDAL, MUS_INTERP_ALL_PASS, MUS_INTERP_LAGRANGE, MUS_INTERP_BEZIER, MUS_INTERP_HERMITE} mus_interp_t; typedef enum {MUS_RECTANGULAR_WINDOW, MUS_HANN_WINDOW, MUS_WELCH_WINDOW, MUS_PARZEN_WINDOW, MUS_BARTLETT_WINDOW, MUS_HAMMING_WINDOW, MUS_BLACKMAN2_WINDOW, MUS_BLACKMAN3_WINDOW, MUS_BLACKMAN4_WINDOW, MUS_EXPONENTIAL_WINDOW, MUS_RIEMANN_WINDOW, MUS_KAISER_WINDOW, MUS_CAUCHY_WINDOW, MUS_POISSON_WINDOW, MUS_GAUSSIAN_WINDOW, MUS_TUKEY_WINDOW, MUS_DOLPH_CHEBYSHEV_WINDOW, MUS_HANN_POISSON_WINDOW, MUS_CONNES_WINDOW, MUS_SAMARAKI_WINDOW, MUS_ULTRASPHERICAL_WINDOW, MUS_BARTLETT_HANN_WINDOW, MUS_BOHMAN_WINDOW, MUS_FLAT_TOP_WINDOW, MUS_BLACKMAN5_WINDOW, MUS_BLACKMAN6_WINDOW, MUS_BLACKMAN7_WINDOW, MUS_BLACKMAN8_WINDOW, MUS_BLACKMAN9_WINDOW, MUS_BLACKMAN10_WINDOW, MUS_RV2_WINDOW, MUS_RV3_WINDOW, MUS_RV4_WINDOW, MUS_MLT_SINE_WINDOW, MUS_PAPOULIS_WINDOW, MUS_DPSS_WINDOW, MUS_SINC_WINDOW, MUS_NUM_FFT_WINDOWS} mus_fft_window_t; typedef enum {MUS_SPECTRUM_IN_DB, MUS_SPECTRUM_NORMALIZED, MUS_SPECTRUM_RAW} mus_spectrum_t; typedef enum {MUS_CHEBYSHEV_EITHER_KIND, MUS_CHEBYSHEV_FIRST_KIND, MUS_CHEBYSHEV_SECOND_KIND} mus_polynomial_t; #define MUS_MAX_CLM_SINC_WIDTH 65536 #define MUS_MAX_CLM_SRC 65536.0 #ifdef __cplusplus extern "C" { #endif MUS_EXPORT void mus_initialize(void); MUS_EXPORT int mus_make_generator_type(void); MUS_EXPORT mus_any_class *mus_generator_class(mus_any *ptr); MUS_EXPORT mus_any_class *mus_make_generator(int type, char *name, int (*release)(mus_any *ptr), char *(*describe)(mus_any *ptr), bool (*equalp)(mus_any *gen1, mus_any *gen2)); MUS_EXPORT void mus_generator_set_release(mus_any_class *p, int (*release)(mus_any *ptr)); MUS_EXPORT void mus_generator_set_describe(mus_any_class *p, char *(*describe)(mus_any *ptr)); MUS_EXPORT void mus_generator_set_equalp(mus_any_class *p, bool (*equalp)(mus_any *gen1, mus_any *gen2)); MUS_EXPORT void mus_generator_set_data(mus_any_class *p, mus_float_t *(*data)(mus_any *ptr)); MUS_EXPORT void mus_generator_set_set_data(mus_any_class *p, mus_float_t *(*set_data)(mus_any *ptr, mus_float_t *new_data)); MUS_EXPORT void mus_generator_set_length(mus_any_class *p, mus_long_t (*length)(mus_any *ptr)); MUS_EXPORT void mus_generator_set_set_length(mus_any_class *p, mus_long_t (*set_length)(mus_any *ptr, mus_long_t new_length)); MUS_EXPORT void mus_generator_set_frequency(mus_any_class *p, mus_float_t (*frequency)(mus_any *ptr)); MUS_EXPORT void mus_generator_set_set_frequency(mus_any_class *p, mus_float_t (*set_frequency)(mus_any *ptr, mus_float_t new_freq)); MUS_EXPORT void mus_generator_set_phase(mus_any_class *p, mus_float_t (*phase)(mus_any *ptr)); MUS_EXPORT void mus_generator_set_set_phase(mus_any_class *p, mus_float_t (*set_phase)(mus_any *ptr, mus_float_t new_phase)); MUS_EXPORT void mus_generator_set_scaler(mus_any_class *p, mus_float_t (*scaler)(mus_any *ptr)); MUS_EXPORT void mus_generator_set_set_scaler(mus_any_class *p, mus_float_t (*set_scaler)(mus_any *ptr, mus_float_t val)); MUS_EXPORT void mus_generator_set_increment(mus_any_class *p, mus_float_t (*increment)(mus_any *ptr)); MUS_EXPORT void mus_generator_set_set_increment(mus_any_class *p, mus_float_t (*set_increment)(mus_any *ptr, mus_float_t val)); MUS_EXPORT void mus_generator_set_run(mus_any_class *p, mus_float_t (*run)(mus_any *gen, mus_float_t arg1, mus_float_t arg2)); MUS_EXPORT void mus_generator_set_closure(mus_any_class *p, void *(*closure)(mus_any *gen)); MUS_EXPORT void mus_generator_set_channels(mus_any_class *p, int (*channels)(mus_any *ptr)); MUS_EXPORT void mus_generator_set_offset(mus_any_class *p, mus_float_t (*offset)(mus_any *ptr)); MUS_EXPORT void mus_generator_set_set_offset(mus_any_class *p, mus_float_t (*set_offset)(mus_any *ptr, mus_float_t val)); MUS_EXPORT void mus_generator_set_width(mus_any_class *p, mus_float_t (*width)(mus_any *ptr)); MUS_EXPORT void mus_generator_set_set_width(mus_any_class *p, mus_float_t (*set_width)(mus_any *ptr, mus_float_t val)); MUS_EXPORT void mus_generator_set_xcoeff(mus_any_class *p, mus_float_t (*xcoeff)(mus_any *ptr, int index)); MUS_EXPORT void mus_generator_set_set_xcoeff(mus_any_class *p, mus_float_t (*set_xcoeff)(mus_any *ptr, int index, mus_float_t val)); MUS_EXPORT void mus_generator_set_hop(mus_any_class *p, mus_long_t (*hop)(mus_any *ptr)); MUS_EXPORT void mus_generator_set_set_hop(mus_any_class *p, mus_long_t (*set_hop)(mus_any *ptr, mus_long_t new_length)); MUS_EXPORT void mus_generator_set_ramp(mus_any_class *p, mus_long_t (*ramp)(mus_any *ptr)); MUS_EXPORT void mus_generator_set_set_ramp(mus_any_class *p, mus_long_t (*set_ramp)(mus_any *ptr, mus_long_t new_length)); MUS_EXPORT void mus_generator_set_read_sample(mus_any_class *p, mus_float_t (*read_sample)(mus_any *ptr, mus_long_t samp, int chan)); MUS_EXPORT void mus_generator_set_write_sample(mus_any_class *p, mus_float_t (*write_sample)(mus_any *ptr, mus_long_t samp, int chan, mus_float_t data)); MUS_EXPORT void mus_generator_set_file_name(mus_any_class *p, char *(*file_name)(mus_any *ptr)); MUS_EXPORT void mus_generator_set_end(mus_any_class *p, int (*end)(mus_any *ptr)); MUS_EXPORT void mus_generator_set_location(mus_any_class *p, mus_long_t (*location)(mus_any *ptr)); MUS_EXPORT void mus_generator_set_set_location(mus_any_class *p, mus_long_t (*set_location)(mus_any *ptr, mus_long_t loc)); MUS_EXPORT void mus_generator_set_channel(mus_any_class *p, int (*channel)(mus_any *ptr)); MUS_EXPORT void mus_generator_set_ycoeff(mus_any_class *p, mus_float_t (*ycoeff)(mus_any *ptr, int index)); MUS_EXPORT void mus_generator_set_set_ycoeff(mus_any_class *p, mus_float_t (*set_ycoeff)(mus_any *ptr, int index, mus_float_t val)); MUS_EXPORT void mus_generator_set_xcoeffs(mus_any_class *p, mus_float_t *(*xcoeffs)(mus_any *ptr)); MUS_EXPORT void mus_generator_set_ycoeffs(mus_any_class *p, mus_float_t *(*ycoeffs)(mus_any *ptr)); MUS_EXPORT void mus_generator_set_reset(mus_any_class *p, void (*reset)(mus_any *ptr)); MUS_EXPORT void mus_generator_set_set_closure(mus_any_class *p, void *(*set_closure)(mus_any *gen, void *e)); MUS_EXPORT void mus_generator_set_extended_type(mus_any_class *p, mus_clm_extended_t extended_type); MUS_EXPORT void mus_generator_set_feeder(mus_any *g, mus_float_t (*feed)(void *arg, int direction)); MUS_EXPORT mus_float_t mus_radians_to_hz(mus_float_t radians); MUS_EXPORT mus_float_t mus_hz_to_radians(mus_float_t hz); MUS_EXPORT mus_float_t mus_degrees_to_radians(mus_float_t degrees); MUS_EXPORT mus_float_t mus_radians_to_degrees(mus_float_t radians); MUS_EXPORT mus_float_t mus_db_to_linear(mus_float_t x); MUS_EXPORT mus_float_t mus_linear_to_db(mus_float_t x); MUS_EXPORT mus_float_t mus_srate(void); MUS_EXPORT mus_float_t mus_set_srate(mus_float_t val); MUS_EXPORT mus_long_t mus_seconds_to_samples(mus_float_t secs); MUS_EXPORT mus_float_t mus_samples_to_seconds(mus_long_t samps); MUS_EXPORT int mus_array_print_length(void); MUS_EXPORT int mus_set_array_print_length(int val); MUS_EXPORT mus_float_t mus_float_equal_fudge_factor(void); MUS_EXPORT mus_float_t mus_set_float_equal_fudge_factor(mus_float_t val); MUS_EXPORT mus_float_t mus_ring_modulate(mus_float_t s1, mus_float_t s2); MUS_EXPORT mus_float_t mus_amplitude_modulate(mus_float_t s1, mus_float_t s2, mus_float_t s3); MUS_EXPORT mus_float_t mus_contrast_enhancement(mus_float_t sig, mus_float_t index); MUS_EXPORT mus_float_t mus_dot_product(mus_float_t *data1, mus_float_t *data2, mus_long_t size); #if HAVE_COMPLEX_TRIG MUS_EXPORT complex double mus_edot_product(complex double freq, complex double *data, mus_long_t size); #endif MUS_EXPORT void mus_clear_array(mus_float_t *arr, mus_long_t size); MUS_EXPORT bool mus_arrays_are_equal(mus_float_t *arr1, mus_float_t *arr2, mus_float_t fudge, mus_long_t len); MUS_EXPORT mus_float_t mus_polynomial(mus_float_t *coeffs, mus_float_t x, int ncoeffs); MUS_EXPORT void mus_multiply_arrays(mus_float_t *data, mus_float_t *window, mus_long_t len); MUS_EXPORT void mus_rectangular_to_polar(mus_float_t *rl, mus_float_t *im, mus_long_t size); MUS_EXPORT void mus_rectangular_to_magnitudes(mus_float_t *rl, mus_float_t *im, mus_long_t size); MUS_EXPORT void mus_polar_to_rectangular(mus_float_t *rl, mus_float_t *im, mus_long_t size); MUS_EXPORT mus_float_t mus_array_interp(mus_float_t *wave, mus_float_t phase, mus_long_t size); MUS_EXPORT double mus_bessi0(mus_float_t x); MUS_EXPORT mus_float_t mus_interpolate(mus_interp_t type, mus_float_t x, mus_float_t *table, mus_long_t table_size, mus_float_t y); MUS_EXPORT bool mus_interp_type_p(int val); MUS_EXPORT bool mus_fft_window_p(int val); MUS_EXPORT int mus_data_format_zero(int format); MUS_EXPORT bool mus_run_exists(mus_any *gen); /* -------- generic functions -------- */ MUS_EXPORT int mus_type(mus_any *ptr); MUS_EXPORT int mus_free(mus_any *ptr); MUS_EXPORT char *mus_describe(mus_any *gen); MUS_EXPORT bool mus_equalp(mus_any *g1, mus_any *g2); MUS_EXPORT mus_float_t mus_phase(mus_any *gen); MUS_EXPORT mus_float_t mus_set_phase(mus_any *gen, mus_float_t val); MUS_EXPORT mus_float_t mus_set_frequency(mus_any *gen, mus_float_t val); MUS_EXPORT mus_float_t mus_frequency(mus_any *gen); MUS_EXPORT mus_float_t mus_run(mus_any *gen, mus_float_t arg1, mus_float_t arg2); MUS_EXPORT mus_long_t mus_length(mus_any *gen); MUS_EXPORT mus_long_t mus_set_length(mus_any *gen, mus_long_t len); MUS_EXPORT mus_long_t mus_order(mus_any *gen); MUS_EXPORT mus_float_t *mus_data(mus_any *gen); MUS_EXPORT mus_float_t *mus_set_data(mus_any *gen, mus_float_t *data); MUS_EXPORT const char *mus_name(mus_any *ptr); MUS_EXPORT const char *mus_set_name(mus_any *ptr, const char *new_name); MUS_EXPORT mus_float_t mus_scaler(mus_any *gen); MUS_EXPORT mus_float_t mus_set_scaler(mus_any *gen, mus_float_t val); MUS_EXPORT mus_float_t mus_offset(mus_any *gen); MUS_EXPORT mus_float_t mus_set_offset(mus_any *gen, mus_float_t val); MUS_EXPORT mus_float_t mus_width(mus_any *gen); MUS_EXPORT mus_float_t mus_set_width(mus_any *gen, mus_float_t val); MUS_EXPORT char *mus_file_name(mus_any *ptr); MUS_EXPORT void mus_reset(mus_any *ptr); MUS_EXPORT mus_float_t *mus_xcoeffs(mus_any *ptr); MUS_EXPORT mus_float_t *mus_ycoeffs(mus_any *ptr); MUS_EXPORT mus_float_t mus_xcoeff(mus_any *ptr, int index); MUS_EXPORT mus_float_t mus_set_xcoeff(mus_any *ptr, int index, mus_float_t val); MUS_EXPORT mus_float_t mus_ycoeff(mus_any *ptr, int index); MUS_EXPORT mus_float_t mus_set_ycoeff(mus_any *ptr, int index, mus_float_t val); MUS_EXPORT mus_float_t mus_increment(mus_any *rd); MUS_EXPORT mus_float_t mus_set_increment(mus_any *rd, mus_float_t dir); MUS_EXPORT mus_long_t mus_location(mus_any *rd); MUS_EXPORT mus_long_t mus_set_location(mus_any *rd, mus_long_t loc); MUS_EXPORT int mus_channel(mus_any *rd); MUS_EXPORT int mus_channels(mus_any *ptr); MUS_EXPORT int mus_position(mus_any *ptr); /* only C, envs (snd-env.c), shares slot with mus_channels */ MUS_EXPORT int mus_interp_type(mus_any *ptr); MUS_EXPORT mus_long_t mus_ramp(mus_any *ptr); MUS_EXPORT mus_long_t mus_set_ramp(mus_any *ptr, mus_long_t val); MUS_EXPORT mus_long_t mus_hop(mus_any *ptr); MUS_EXPORT mus_long_t mus_set_hop(mus_any *ptr, mus_long_t val); MUS_EXPORT mus_float_t mus_feedforward(mus_any *gen); MUS_EXPORT mus_float_t mus_set_feedforward(mus_any *gen, mus_float_t val); MUS_EXPORT mus_float_t mus_feedback(mus_any *rd); MUS_EXPORT mus_float_t mus_set_feedback(mus_any *rd, mus_float_t dir); /* -------- generators -------- */ MUS_EXPORT mus_float_t mus_oscil(mus_any *o, mus_float_t fm, mus_float_t pm); MUS_EXPORT mus_float_t mus_oscil_unmodulated(mus_any *ptr); MUS_EXPORT mus_float_t mus_oscil_fm(mus_any *ptr, mus_float_t fm); MUS_EXPORT mus_float_t mus_oscil_pm(mus_any *ptr, mus_float_t pm); MUS_EXPORT bool mus_oscil_p(mus_any *ptr); MUS_EXPORT mus_any *mus_make_oscil(mus_float_t freq, mus_float_t phase); MUS_EXPORT bool mus_oscil_bank_p(mus_any *ptr); MUS_EXPORT mus_float_t mus_oscil_bank(mus_any *ptr); MUS_EXPORT mus_any *mus_make_oscil_bank(int size, mus_float_t *freqs, mus_float_t *phases, mus_float_t *amps); MUS_EXPORT mus_any *mus_make_ncos(mus_float_t freq, int n); MUS_EXPORT mus_float_t mus_ncos(mus_any *ptr, mus_float_t fm); MUS_EXPORT bool mus_ncos_p(mus_any *ptr); MUS_EXPORT mus_any *mus_make_nsin(mus_float_t freq, int n); MUS_EXPORT mus_float_t mus_nsin(mus_any *ptr, mus_float_t fm); MUS_EXPORT bool mus_nsin_p(mus_any *ptr); MUS_EXPORT mus_any *mus_make_nrxysin(mus_float_t frequency, mus_float_t y_over_x, int n, mus_float_t r); MUS_EXPORT mus_float_t mus_nrxysin(mus_any *ptr, mus_float_t fm); MUS_EXPORT bool mus_nrxysin_p(mus_any *ptr); MUS_EXPORT mus_any *mus_make_nrxycos(mus_float_t frequency, mus_float_t y_over_x, int n, mus_float_t r); MUS_EXPORT mus_float_t mus_nrxycos(mus_any *ptr, mus_float_t fm); MUS_EXPORT bool mus_nrxycos_p(mus_any *ptr); MUS_EXPORT mus_any *mus_make_rxykcos(mus_float_t freq, mus_float_t phase, mus_float_t r, mus_float_t ratio); MUS_EXPORT mus_float_t mus_rxykcos(mus_any *ptr, mus_float_t fm); MUS_EXPORT bool mus_rxykcos_p(mus_any *ptr); MUS_EXPORT mus_any *mus_make_rxyksin(mus_float_t freq, mus_float_t phase, mus_float_t r, mus_float_t ratio); MUS_EXPORT mus_float_t mus_rxyksin(mus_any *ptr, mus_float_t fm); MUS_EXPORT bool mus_rxyksin_p(mus_any *ptr); MUS_EXPORT mus_float_t mus_delay(mus_any *gen, mus_float_t input, mus_float_t pm); MUS_EXPORT mus_float_t mus_delay_unmodulated(mus_any *ptr, mus_float_t input); MUS_EXPORT mus_float_t mus_tap(mus_any *gen, mus_float_t loc); MUS_EXPORT mus_float_t mus_tap_unmodulated(mus_any *gen); MUS_EXPORT mus_any *mus_make_delay(int size, mus_float_t *line, int line_size, mus_interp_t type); MUS_EXPORT bool mus_delay_p(mus_any *ptr); MUS_EXPORT bool mus_tap_p(mus_any *ptr); MUS_EXPORT bool mus_delay_line_p(mus_any *gen); /* added 2-Mar-03 for tap error checks */ MUS_EXPORT mus_float_t mus_delay_tick(mus_any *ptr, mus_float_t input); MUS_EXPORT mus_float_t mus_delay_unmodulated_noz(mus_any *ptr, mus_float_t input); MUS_EXPORT mus_float_t mus_comb(mus_any *gen, mus_float_t input, mus_float_t pm); MUS_EXPORT mus_float_t mus_comb_unmodulated(mus_any *gen, mus_float_t input); MUS_EXPORT mus_any *mus_make_comb(mus_float_t scaler, int size, mus_float_t *line, int line_size, mus_interp_t type); MUS_EXPORT bool mus_comb_p(mus_any *ptr); MUS_EXPORT mus_float_t mus_comb_unmodulated_noz(mus_any *ptr, mus_float_t input); MUS_EXPORT mus_float_t mus_comb_bank(mus_any *bank, mus_float_t inval); MUS_EXPORT mus_any *mus_make_comb_bank(int size, mus_any **combs); MUS_EXPORT bool mus_comb_bank_p(mus_any *g); MUS_EXPORT mus_float_t mus_notch(mus_any *gen, mus_float_t input, mus_float_t pm); MUS_EXPORT mus_float_t mus_notch_unmodulated(mus_any *gen, mus_float_t input); MUS_EXPORT mus_any *mus_make_notch(mus_float_t scaler, int size, mus_float_t *line, int line_size, mus_interp_t type); MUS_EXPORT bool mus_notch_p(mus_any *ptr); MUS_EXPORT mus_float_t mus_notch_unmodulated_noz(mus_any *ptr, mus_float_t input); MUS_EXPORT mus_float_t mus_all_pass(mus_any *gen, mus_float_t input, mus_float_t pm); MUS_EXPORT mus_float_t mus_all_pass_unmodulated(mus_any *gen, mus_float_t input); MUS_EXPORT mus_any *mus_make_all_pass(mus_float_t backward, mus_float_t forward, int size, mus_float_t *line, int line_size, mus_interp_t type); MUS_EXPORT bool mus_all_pass_p(mus_any *ptr); MUS_EXPORT mus_float_t mus_all_pass_unmodulated_noz(mus_any *ptr, mus_float_t input); MUS_EXPORT mus_float_t mus_all_pass_bank(mus_any *bank, mus_float_t inval); MUS_EXPORT mus_any *mus_make_all_pass_bank(int size, mus_any **combs); MUS_EXPORT bool mus_all_pass_bank_p(mus_any *g); MUS_EXPORT mus_any *mus_make_moving_average(int size, mus_float_t *line); MUS_EXPORT bool mus_moving_average_p(mus_any *ptr); MUS_EXPORT mus_float_t mus_moving_average(mus_any *ptr, mus_float_t input); MUS_EXPORT mus_any *mus_make_moving_max(int size, mus_float_t *line); MUS_EXPORT bool mus_moving_max_p(mus_any *ptr); MUS_EXPORT mus_float_t mus_moving_max(mus_any *ptr, mus_float_t input); MUS_EXPORT mus_float_t mus_table_lookup(mus_any *gen, mus_float_t fm); MUS_EXPORT mus_float_t mus_table_lookup_unmodulated(mus_any *gen); MUS_EXPORT mus_any *mus_make_table_lookup(mus_float_t freq, mus_float_t phase, mus_float_t *wave, mus_long_t wave_size, mus_interp_t type); MUS_EXPORT bool mus_table_lookup_p(mus_any *ptr); MUS_EXPORT mus_float_t *mus_partials_to_wave(mus_float_t *partial_data, int partials, mus_float_t *table, mus_long_t table_size, bool normalize); MUS_EXPORT mus_float_t *mus_phase_partials_to_wave(mus_float_t *partial_data, int partials, mus_float_t *table, mus_long_t table_size, bool normalize); MUS_EXPORT mus_float_t mus_sawtooth_wave(mus_any *gen, mus_float_t fm); MUS_EXPORT mus_any *mus_make_sawtooth_wave(mus_float_t freq, mus_float_t amp, mus_float_t phase); MUS_EXPORT bool mus_sawtooth_wave_p(mus_any *gen); MUS_EXPORT mus_float_t mus_square_wave(mus_any *gen, mus_float_t fm); MUS_EXPORT mus_any *mus_make_square_wave(mus_float_t freq, mus_float_t amp, mus_float_t phase); MUS_EXPORT bool mus_square_wave_p(mus_any *gen); MUS_EXPORT mus_float_t mus_triangle_wave(mus_any *gen, mus_float_t fm); MUS_EXPORT mus_any *mus_make_triangle_wave(mus_float_t freq, mus_float_t amp, mus_float_t phase); MUS_EXPORT bool mus_triangle_wave_p(mus_any *gen); MUS_EXPORT mus_float_t mus_triangle_wave_unmodulated(mus_any *ptr); MUS_EXPORT mus_float_t mus_pulse_train(mus_any *gen, mus_float_t fm); MUS_EXPORT mus_any *mus_make_pulse_train(mus_float_t freq, mus_float_t amp, mus_float_t phase); MUS_EXPORT bool mus_pulse_train_p(mus_any *gen); MUS_EXPORT mus_float_t mus_pulse_train_unmodulated(mus_any *ptr); MUS_EXPORT void mus_set_rand_seed(unsigned long seed); MUS_EXPORT unsigned long mus_rand_seed(void); MUS_EXPORT mus_float_t mus_random(mus_float_t amp); MUS_EXPORT mus_float_t mus_frandom(mus_float_t amp); MUS_EXPORT int mus_irandom(int amp); MUS_EXPORT mus_float_t mus_rand(mus_any *gen, mus_float_t fm); MUS_EXPORT mus_any *mus_make_rand(mus_float_t freq, mus_float_t base); MUS_EXPORT bool mus_rand_p(mus_any *ptr); MUS_EXPORT mus_any *mus_make_rand_with_distribution(mus_float_t freq, mus_float_t base, mus_float_t *distribution, int distribution_size); MUS_EXPORT mus_float_t mus_rand_interp(mus_any *gen, mus_float_t fm); MUS_EXPORT mus_any *mus_make_rand_interp(mus_float_t freq, mus_float_t base); MUS_EXPORT bool mus_rand_interp_p(mus_any *ptr); MUS_EXPORT mus_any *mus_make_rand_interp_with_distribution(mus_float_t freq, mus_float_t base, mus_float_t *distribution, int distribution_size); MUS_EXPORT mus_float_t mus_rand_interp_unmodulated(mus_any *ptr); MUS_EXPORT mus_float_t mus_rand_unmodulated(mus_any *ptr); MUS_EXPORT mus_float_t mus_asymmetric_fm(mus_any *gen, mus_float_t index, mus_float_t fm); MUS_EXPORT mus_float_t mus_asymmetric_fm_unmodulated(mus_any *gen, mus_float_t index); MUS_EXPORT mus_any *mus_make_asymmetric_fm(mus_float_t freq, mus_float_t phase, mus_float_t r, mus_float_t ratio); MUS_EXPORT bool mus_asymmetric_fm_p(mus_any *ptr); MUS_EXPORT mus_float_t mus_one_zero(mus_any *gen, mus_float_t input); MUS_EXPORT mus_any *mus_make_one_zero(mus_float_t a0, mus_float_t a1); MUS_EXPORT bool mus_one_zero_p(mus_any *gen); MUS_EXPORT mus_float_t mus_one_pole(mus_any *gen, mus_float_t input); MUS_EXPORT mus_any *mus_make_one_pole(mus_float_t a0, mus_float_t b1); MUS_EXPORT bool mus_one_pole_p(mus_any *gen); MUS_EXPORT mus_float_t mus_two_zero(mus_any *gen, mus_float_t input); MUS_EXPORT mus_any *mus_make_two_zero(mus_float_t a0, mus_float_t a1, mus_float_t a2); MUS_EXPORT bool mus_two_zero_p(mus_any *gen); MUS_EXPORT mus_any *mus_make_two_zero_from_frequency_and_radius(mus_float_t frequency, mus_float_t radius); MUS_EXPORT mus_float_t mus_two_pole(mus_any *gen, mus_float_t input); MUS_EXPORT mus_any *mus_make_two_pole(mus_float_t a0, mus_float_t b1, mus_float_t b2); MUS_EXPORT bool mus_two_pole_p(mus_any *gen); MUS_EXPORT mus_any *mus_make_two_pole_from_frequency_and_radius(mus_float_t frequency, mus_float_t radius); MUS_EXPORT mus_float_t mus_one_pole_all_pass(mus_any *f, mus_float_t input); MUS_EXPORT mus_any *mus_make_one_pole_all_pass(int size, mus_float_t coeff); MUS_EXPORT bool mus_one_pole_all_pass_p(mus_any *ptr); MUS_EXPORT mus_float_t mus_formant(mus_any *ptr, mus_float_t input); MUS_EXPORT mus_any *mus_make_formant(mus_float_t frequency, mus_float_t radius); MUS_EXPORT bool mus_formant_p(mus_any *ptr); MUS_EXPORT void mus_set_formant_radius_and_frequency(mus_any *ptr, mus_float_t radius, mus_float_t frequency); MUS_EXPORT mus_float_t mus_formant_with_frequency(mus_any *ptr, mus_float_t input, mus_float_t freq_in_radians); MUS_EXPORT mus_float_t mus_formant_bank(mus_any *bank, mus_float_t inval); MUS_EXPORT mus_float_t mus_formant_bank_with_inputs(mus_any *bank, mus_float_t *inval); MUS_EXPORT mus_any *mus_make_formant_bank(int size, mus_any **formants, mus_float_t *amps); MUS_EXPORT bool mus_formant_bank_p(mus_any *g); MUS_EXPORT mus_float_t mus_firmant(mus_any *ptr, mus_float_t input); MUS_EXPORT mus_any *mus_make_firmant(mus_float_t frequency, mus_float_t radius); MUS_EXPORT bool mus_firmant_p(mus_any *ptr); MUS_EXPORT mus_float_t mus_firmant_with_frequency(mus_any *ptr, mus_float_t input, mus_float_t freq_in_radians); MUS_EXPORT mus_float_t mus_filter(mus_any *ptr, mus_float_t input); MUS_EXPORT mus_any *mus_make_filter(int order, mus_float_t *xcoeffs, mus_float_t *ycoeffs, mus_float_t *state); MUS_EXPORT bool mus_filter_p(mus_any *ptr); MUS_EXPORT mus_float_t mus_fir_filter(mus_any *ptr, mus_float_t input); MUS_EXPORT mus_any *mus_make_fir_filter(int order, mus_float_t *xcoeffs, mus_float_t *state); MUS_EXPORT bool mus_fir_filter_p(mus_any *ptr); MUS_EXPORT mus_float_t mus_iir_filter(mus_any *ptr, mus_float_t input); MUS_EXPORT mus_any *mus_make_iir_filter(int order, mus_float_t *ycoeffs, mus_float_t *state); MUS_EXPORT bool mus_iir_filter_p(mus_any *ptr); MUS_EXPORT mus_float_t *mus_make_fir_coeffs(int order, mus_float_t *env, mus_float_t *aa); MUS_EXPORT mus_float_t *mus_filter_set_xcoeffs(mus_any *ptr, mus_float_t *new_data); MUS_EXPORT mus_float_t *mus_filter_set_ycoeffs(mus_any *ptr, mus_float_t *new_data); MUS_EXPORT int mus_filter_set_order(mus_any *ptr, int order); MUS_EXPORT mus_float_t mus_filtered_comb(mus_any *ptr, mus_float_t input, mus_float_t pm); MUS_EXPORT mus_float_t mus_filtered_comb_unmodulated(mus_any *ptr, mus_float_t input); MUS_EXPORT bool mus_filtered_comb_p(mus_any *ptr); MUS_EXPORT mus_any *mus_make_filtered_comb(mus_float_t scaler, int size, mus_float_t *line, int line_size, mus_interp_t type, mus_any *filt); MUS_EXPORT mus_float_t mus_filtered_comb_bank(mus_any *bank, mus_float_t inval); MUS_EXPORT mus_any *mus_make_filtered_comb_bank(int size, mus_any **combs); MUS_EXPORT bool mus_filtered_comb_bank_p(mus_any *g); MUS_EXPORT mus_float_t mus_wave_train(mus_any *gen, mus_float_t fm); MUS_EXPORT mus_float_t mus_wave_train_unmodulated(mus_any *gen); MUS_EXPORT mus_any *mus_make_wave_train(mus_float_t freq, mus_float_t phase, mus_float_t *wave, mus_long_t wsize, mus_interp_t type); MUS_EXPORT bool mus_wave_train_p(mus_any *gen); MUS_EXPORT mus_float_t *mus_partials_to_polynomial(int npartials, mus_float_t *partials, mus_polynomial_t kind); MUS_EXPORT mus_float_t *mus_normalize_partials(int num_partials, mus_float_t *partials); MUS_EXPORT mus_any *mus_make_polyshape(mus_float_t frequency, mus_float_t phase, mus_float_t *coeffs, int size, int cheby_choice); MUS_EXPORT mus_float_t mus_polyshape(mus_any *ptr, mus_float_t index, mus_float_t fm); MUS_EXPORT mus_float_t mus_polyshape_unmodulated(mus_any *ptr, mus_float_t index); #define mus_polyshape_no_input(Obj) mus_polyshape(Obj, 1.0, 0.0) MUS_EXPORT bool mus_polyshape_p(mus_any *ptr); MUS_EXPORT mus_any *mus_make_polywave(mus_float_t frequency, mus_float_t *coeffs, int n, int cheby_choice); MUS_EXPORT bool mus_polywave_p(mus_any *ptr); MUS_EXPORT mus_float_t mus_polywave_unmodulated(mus_any *ptr); MUS_EXPORT mus_float_t mus_polywave(mus_any *ptr, mus_float_t fm); MUS_EXPORT mus_float_t mus_chebyshev_t_sum(mus_float_t x, int n, mus_float_t *tn); MUS_EXPORT mus_float_t mus_chebyshev_u_sum(mus_float_t x, int n, mus_float_t *un); MUS_EXPORT mus_float_t mus_chebyshev_tu_sum(mus_float_t x, int n, mus_float_t *tn, mus_float_t *un); MUS_EXPORT mus_float_t mus_env(mus_any *ptr); MUS_EXPORT mus_any *mus_make_env(mus_float_t *brkpts, int npts, double scaler, double offset, double base, double duration, mus_long_t end, mus_float_t *odata); MUS_EXPORT bool mus_env_p(mus_any *ptr); MUS_EXPORT double mus_env_interp(double x, mus_any *env); MUS_EXPORT mus_long_t *mus_env_passes(mus_any *gen); /* for Snd */ MUS_EXPORT double *mus_env_rates(mus_any *gen); /* for Snd */ MUS_EXPORT double mus_env_offset(mus_any *gen); /* for Snd */ MUS_EXPORT double mus_env_scaler(mus_any *gen); /* for Snd */ MUS_EXPORT double mus_env_initial_power(mus_any *gen); /* for Snd */ MUS_EXPORT int mus_env_breakpoints(mus_any *gen); /* for Snd */ MUS_EXPORT mus_float_t mus_env_any(mus_any *e, mus_float_t (*connect_points)(mus_float_t val)); #define mus_make_env_with_length(Brkpts, Pts, Scaler, Offset, Base, Length) mus_make_env(Brkpts, Pts, Scaler, Offset, Base, 0.0, (Length) - 1, NULL) MUS_EXPORT mus_any *mus_make_pulsed_env(mus_any *e, mus_any *p); MUS_EXPORT bool mus_pulsed_env_p(mus_any *ptr); MUS_EXPORT mus_float_t mus_pulsed_env(mus_any *pl, mus_float_t inval); MUS_EXPORT mus_float_t mus_pulsed_env_unmodulated(mus_any *pl); MUS_EXPORT bool mus_frame_p(mus_any *ptr); MUS_EXPORT bool mus_frame_or_mixer_p(mus_any *ptr); MUS_EXPORT mus_any *mus_make_empty_frame(int chans); MUS_EXPORT mus_any *mus_make_frame(int chans, ...); MUS_EXPORT mus_any *mus_frame_add(mus_any *f1, mus_any *f2, mus_any *res); MUS_EXPORT mus_any *mus_frame_multiply(mus_any *f1, mus_any *f2, mus_any *res); MUS_EXPORT mus_any *mus_frame_scale(mus_any *uf1, mus_float_t scl, mus_any *ures); MUS_EXPORT mus_any *mus_frame_offset(mus_any *uf1, mus_float_t offset, mus_any *ures); MUS_EXPORT mus_float_t mus_frame_ref(mus_any *f, int chan); MUS_EXPORT mus_float_t mus_frame_set(mus_any *f, int chan, mus_float_t val); MUS_EXPORT mus_any *mus_frame_copy(mus_any *uf); MUS_EXPORT mus_float_t mus_frame_fill(mus_any *uf, mus_float_t val); MUS_EXPORT bool mus_mixer_p(mus_any *ptr); MUS_EXPORT mus_any *mus_make_empty_mixer(int chans); MUS_EXPORT mus_any *mus_make_identity_mixer(int chans); MUS_EXPORT mus_any *mus_make_mixer(int chans, ...); MUS_EXPORT mus_float_t mus_mixer_ref(mus_any *f, int in, int out); MUS_EXPORT mus_float_t mus_mixer_set(mus_any *f, int in, int out, mus_float_t val); MUS_EXPORT mus_any *mus_frame_to_frame(mus_any *f, mus_any *in, mus_any *out); MUS_EXPORT mus_any *mus_sample_to_frame(mus_any *f, mus_float_t in, mus_any *out); MUS_EXPORT mus_float_t mus_frame_to_sample(mus_any *f, mus_any *in); MUS_EXPORT mus_any *mus_mixer_multiply(mus_any *f1, mus_any *f2, mus_any *res); MUS_EXPORT mus_any *mus_mixer_add(mus_any *f1, mus_any *f2, mus_any *res); MUS_EXPORT mus_any *mus_mixer_scale(mus_any *uf1, mus_float_t scaler, mus_any *ures); MUS_EXPORT mus_any *mus_mixer_offset(mus_any *uf1, mus_float_t offset, mus_any *ures); MUS_EXPORT mus_any *mus_make_scalar_mixer(int chans, mus_float_t scalar); MUS_EXPORT mus_any *mus_mixer_copy(mus_any *uf); MUS_EXPORT mus_float_t mus_mixer_fill(mus_any *uf, mus_float_t val); MUS_EXPORT bool mus_file_to_sample_p(mus_any *ptr); MUS_EXPORT mus_any *mus_make_file_to_sample(const char *filename); MUS_EXPORT mus_any *mus_make_file_to_sample_with_buffer_size(const char *filename, mus_long_t buffer_size); MUS_EXPORT mus_float_t mus_file_to_sample(mus_any *ptr, mus_long_t samp, int chan); MUS_EXPORT mus_float_t mus_in_any_from_file(mus_any *ptr, mus_long_t samp, int chan); MUS_EXPORT mus_float_t mus_readin(mus_any *rd); MUS_EXPORT mus_any *mus_make_readin_with_buffer_size(const char *filename, int chan, mus_long_t start, int direction, mus_long_t buffer_size); #define mus_make_readin(Filename, Chan, Start, Direction) mus_make_readin_with_buffer_size(Filename, Chan, Start, Direction, mus_file_buffer_size()) MUS_EXPORT bool mus_readin_p(mus_any *ptr); MUS_EXPORT bool mus_output_p(mus_any *ptr); MUS_EXPORT bool mus_input_p(mus_any *ptr); MUS_EXPORT mus_float_t mus_in_any(mus_long_t frame, int chan, mus_any *IO); MUS_EXPORT bool mus_in_any_is_safe(mus_any *IO); MUS_EXPORT mus_any *mus_make_file_to_frame(const char *filename); MUS_EXPORT bool mus_file_to_frame_p(mus_any *ptr); MUS_EXPORT mus_any *mus_file_to_frame(mus_any *ptr, mus_long_t samp, mus_any *f); MUS_EXPORT mus_any *mus_make_file_to_frame_with_buffer_size(const char *filename, mus_long_t buffer_size); MUS_EXPORT bool mus_sample_to_file_p(mus_any *ptr); MUS_EXPORT mus_any *mus_make_sample_to_file_with_comment(const char *filename, int out_chans, int out_format, int out_type, const char *comment); #define mus_make_sample_to_file(Filename, Chans, OutFormat, OutType) mus_make_sample_to_file_with_comment(Filename, Chans, OutFormat, OutType, NULL) MUS_EXPORT mus_float_t mus_sample_to_file(mus_any *ptr, mus_long_t samp, int chan, mus_float_t val); MUS_EXPORT mus_any *mus_continue_sample_to_file(const char *filename); MUS_EXPORT int mus_close_file(mus_any *ptr); MUS_EXPORT mus_any *mus_sample_to_file_add(mus_any *out1, mus_any *out2); MUS_EXPORT mus_float_t mus_out_any(mus_long_t frame, mus_float_t val, int chan, mus_any *IO); MUS_EXPORT mus_float_t mus_safe_out_any_to_file(mus_long_t samp, mus_float_t val, int chan, mus_any *IO); MUS_EXPORT bool mus_out_any_is_safe(mus_any *IO); MUS_EXPORT mus_float_t mus_out_any_to_file(mus_any *ptr, mus_long_t samp, int chan, mus_float_t val); MUS_EXPORT mus_long_t mus_out_any_data_start(mus_any *IO); MUS_EXPORT mus_long_t mus_out_any_data_end(mus_any *IO); MUS_EXPORT int mus_out_any_channels(mus_any *IO); MUS_EXPORT mus_float_t **mus_out_any_buffers(mus_any *IO); MUS_EXPORT void mus_out_any_set_end(mus_any *IO, mus_long_t end); MUS_EXPORT bool mus_frame_to_file_p(mus_any *ptr); MUS_EXPORT mus_any *mus_frame_to_file(mus_any *ptr, mus_long_t samp, mus_any *data); MUS_EXPORT mus_any *mus_make_frame_to_file_with_comment(const char *filename, int chans, int out_format, int out_type, const char *comment); #define mus_make_frame_to_file(Filename, Chans, OutFormat, OutType) mus_make_frame_to_file_with_comment(Filename, Chans, OutFormat, OutType, NULL) MUS_EXPORT mus_any *mus_continue_frame_to_file(const char *filename); MUS_EXPORT void mus_locsig(mus_any *ptr, mus_long_t loc, mus_float_t val); MUS_EXPORT mus_any *mus_make_locsig(mus_float_t degree, mus_float_t distance, mus_float_t reverb, int chans, mus_any *output, int rev_chans, mus_any *revput, mus_interp_t type); MUS_EXPORT bool mus_locsig_p(mus_any *ptr); MUS_EXPORT mus_float_t mus_locsig_ref(mus_any *ptr, int chan); MUS_EXPORT mus_float_t mus_locsig_set(mus_any *ptr, int chan, mus_float_t val); MUS_EXPORT mus_float_t mus_locsig_reverb_ref(mus_any *ptr, int chan); MUS_EXPORT mus_float_t mus_locsig_reverb_set(mus_any *ptr, int chan, mus_float_t val); MUS_EXPORT void mus_move_locsig(mus_any *ptr, mus_float_t degree, mus_float_t distance); MUS_EXPORT mus_any *mus_locsig_outf(mus_any *ptr); MUS_EXPORT mus_any *mus_locsig_revf(mus_any *ptr); MUS_EXPORT void *mus_locsig_closure(mus_any *ptr); MUS_EXPORT void mus_locsig_set_detour(mus_any *ptr, void (*detour)(mus_any *ptr, mus_long_t val)); MUS_EXPORT bool mus_locsig_output_is_safe(mus_any *ptr); MUS_EXPORT int mus_locsig_channels(mus_any *ptr); MUS_EXPORT int mus_locsig_reverb_channels(mus_any *ptr); MUS_EXPORT mus_any *mus_locsig_out_writer(mus_any *ptr); MUS_EXPORT mus_any *mus_locsig_rev_writer(mus_any *ptr); MUS_EXPORT bool mus_move_sound_p(mus_any *ptr); MUS_EXPORT mus_float_t mus_move_sound(mus_any *ptr, mus_long_t loc, mus_float_t val); MUS_EXPORT mus_any *mus_make_move_sound(mus_long_t start, mus_long_t end, int out_channels, int rev_channels, mus_any *doppler_delay, mus_any *doppler_env, mus_any *rev_env, mus_any **out_delays, mus_any **out_envs, mus_any **rev_envs, int *out_map, mus_any *output, mus_any *revput, bool free_arrays, bool free_gens); MUS_EXPORT mus_any *mus_move_sound_outf(mus_any *ptr); MUS_EXPORT mus_any *mus_move_sound_revf(mus_any *ptr); MUS_EXPORT void *mus_move_sound_closure(mus_any *ptr); MUS_EXPORT void mus_move_sound_set_detour(mus_any *ptr, void (*detour)(mus_any *ptr, mus_long_t val)); MUS_EXPORT mus_any *mus_make_src(mus_float_t (*input)(void *arg, int direction), mus_float_t srate, int width, void *closure); MUS_EXPORT mus_any *mus_make_src_with_init(mus_float_t (*input)(void *arg, int direction), mus_float_t srate, int width, void *closure, void (*init)(void *p, mus_any *g)); MUS_EXPORT mus_float_t mus_src(mus_any *srptr, mus_float_t sr_change, mus_float_t (*input)(void *arg, int direction)); MUS_EXPORT bool mus_src_p(mus_any *ptr); MUS_EXPORT mus_float_t mus_src_20(mus_any *srptr, mus_float_t (*input)(void *arg, int direction)); MUS_EXPORT mus_float_t mus_src_05(mus_any *srptr, mus_float_t (*input)(void *arg, int direction)); MUS_EXPORT bool mus_convolve_p(mus_any *ptr); MUS_EXPORT mus_float_t mus_convolve(mus_any *ptr, mus_float_t (*input)(void *arg, int direction)); MUS_EXPORT mus_any *mus_make_convolve(mus_float_t (*input)(void *arg, int direction), mus_float_t *filter, mus_long_t fftsize, mus_long_t filtersize, void *closure); MUS_EXPORT mus_float_t *mus_spectrum(mus_float_t *rdat, mus_float_t *idat, mus_float_t *window, mus_long_t n, mus_spectrum_t type); MUS_EXPORT void mus_fft(mus_float_t *rl, mus_float_t *im, mus_long_t n, int is); MUS_EXPORT mus_float_t *mus_make_fft_window(mus_fft_window_t type, mus_long_t size, mus_float_t beta); MUS_EXPORT mus_float_t *mus_make_fft_window_with_window(mus_fft_window_t type, mus_long_t size, mus_float_t beta, mus_float_t mu, mus_float_t *window); MUS_EXPORT const char *mus_fft_window_name(mus_fft_window_t win); MUS_EXPORT const char **mus_fft_window_names(void); MUS_EXPORT mus_float_t *mus_autocorrelate(mus_float_t *data, mus_long_t n); MUS_EXPORT mus_float_t *mus_correlate(mus_float_t *data1, mus_float_t *data2, mus_long_t n); MUS_EXPORT mus_float_t *mus_convolution(mus_float_t *rl1, mus_float_t *rl2, mus_long_t n); MUS_EXPORT void mus_convolve_files(const char *file1, const char *file2, mus_float_t maxamp, const char *output_file); MUS_EXPORT mus_float_t *mus_cepstrum(mus_float_t *data, mus_long_t n); MUS_EXPORT bool mus_granulate_p(mus_any *ptr); MUS_EXPORT mus_float_t mus_granulate(mus_any *ptr, mus_float_t (*input)(void *arg, int direction)); MUS_EXPORT mus_float_t mus_granulate_with_editor(mus_any *ptr, mus_float_t (*input)(void *arg, int direction), int (*edit)(void *closure)); MUS_EXPORT mus_any *mus_make_granulate(mus_float_t (*input)(void *arg, int direction), mus_float_t expansion, mus_float_t length, mus_float_t scaler, mus_float_t hop, mus_float_t ramp, mus_float_t jitter, int max_size, int (*edit)(void *closure), void *closure); MUS_EXPORT int mus_granulate_grain_max_length(mus_any *ptr); MUS_EXPORT void mus_granulate_set_edit_function(mus_any *ptr, int (*edit)(void *closure)); MUS_EXPORT mus_long_t mus_set_file_buffer_size(mus_long_t size); MUS_EXPORT mus_long_t mus_file_buffer_size(void); MUS_EXPORT void mus_mix(const char *outfile, const char *infile, mus_long_t out_start, mus_long_t out_samps, mus_long_t in_start, mus_any *mx, mus_any ***envs); MUS_EXPORT void mus_mix_with_reader_and_writer(mus_any *outf, mus_any *inf, mus_long_t out_start, mus_long_t out_frames, mus_long_t in_start, mus_any *umx, mus_any ***envs); MUS_EXPORT mus_float_t mus_apply(mus_any *gen, mus_float_t f1, mus_float_t f2); MUS_EXPORT bool mus_phase_vocoder_p(mus_any *ptr); MUS_EXPORT mus_any *mus_make_phase_vocoder(mus_float_t (*input)(void *arg, int direction), int fftsize, int overlap, int interp, mus_float_t pitch, bool (*analyze)(void *arg, mus_float_t (*input)(void *arg1, int direction)), int (*edit)(void *arg), /* return value is ignored (int return type is intended to be consistent with granulate) */ mus_float_t (*synthesize)(void *arg), void *closure); MUS_EXPORT mus_float_t mus_phase_vocoder(mus_any *ptr, mus_float_t (*input)(void *arg, int direction)); MUS_EXPORT mus_float_t mus_phase_vocoder_with_editors(mus_any *ptr, mus_float_t (*input)(void *arg, int direction), bool (*analyze)(void *arg, mus_float_t (*input)(void *arg1, int direction)), int (*edit)(void *arg), mus_float_t (*synthesize)(void *arg)); MUS_EXPORT mus_float_t *mus_phase_vocoder_amp_increments(mus_any *ptr); MUS_EXPORT mus_float_t *mus_phase_vocoder_amps(mus_any *ptr); MUS_EXPORT mus_float_t *mus_phase_vocoder_freqs(mus_any *ptr); MUS_EXPORT mus_float_t *mus_phase_vocoder_phases(mus_any *ptr); MUS_EXPORT mus_float_t *mus_phase_vocoder_phase_increments(mus_any *ptr); MUS_EXPORT mus_any *mus_make_ssb_am(mus_float_t freq, int order); MUS_EXPORT bool mus_ssb_am_p(mus_any *ptr); MUS_EXPORT mus_float_t mus_ssb_am_unmodulated(mus_any *ptr, mus_float_t insig); MUS_EXPORT mus_float_t mus_ssb_am(mus_any *ptr, mus_float_t insig, mus_float_t fm); MUS_EXPORT void mus_clear_sinc_tables(void); MUS_EXPORT void *mus_environ(mus_any *gen); MUS_EXPORT void *mus_set_environ(mus_any *gen, void *e); /* used only in run.lisp */ MUS_EXPORT mus_any *mus_make_frame_with_data(int chans, mus_float_t *data); MUS_EXPORT mus_any *mus_make_mixer_with_data(int chans, mus_float_t *data); #ifdef __cplusplus } #endif #endif /* Change log. * * 19-Apr: rxyk!cos and rxyk!sin from generators.scm. * 11-Apr: mus_tap_p as a better name for mus_delay_line_p. * 27-Mar: comb-bank, all-pass-bank, filtered-comb-bank, pulsed-env, oscil-bank. * 21-Mar: one-pole-all-pass generator. * 14-Mar: formant-bank generator. * removed mus_delay_tick_noz. * 4-Mar: moving_max generator. * removed the unstable filter check in make_two_pole. * 21-Jan-13: changed mus_formant_bank parameters. * -------- * 22-Dec: removed all the safety settings. * 15-Nov: removed mus_env_t, mus_env_type, and other recently deprecated stuff. * 15-Jul: more changes for clm2xen. * 4-July-12: moved various struct definitions to clm.c * added accessors for mus_any_class etc. * -------- * 1-Sep: mus_type. * 20-Aug: changed type of mus_locsig to void, added mus_locsig_function_reset. * removed function-as-output-location from locsig et al. * 14-Jul-11: removed pthread stuff. * -------- * 7-Mar-10: protect in-any and out-any from sample numbers less than 0. * -------- * 14-Oct: sine-summation, sum-of-sines, sum-of-cosines removed. * 28-Aug: changed some fft-related sizes from int to mus_long_t. * 17-Aug: mus_frame|mixer_copy|fill. * 27-Jul: mus_float_t for Float, and mus_long_t for off_t. * 15-Jun: mus_rectangular_to_magnitudes (polar, but ignore phases). * 11-Jun: mus_cepstrum. * 11-May: MUS_ENV_LINEAR and friends, also mus_env_linear|exponential. * mus_frame_to_frame_mono|stereo. * 12-Mar: sinc, papoulis and dpss (slepian windows). * 1-Jan-09: added MUS_EXPORT. * -------- * 11-Dec: deprecated the sine-summation, sum-of-cosines, and sum-of-sines generators. * 30-Oct: mus_sample_to_file_add. * mus_describe once again allocates a fresh output string. * finally removed sine-bank. * 9-Oct: various thread-related internal changes. * 14-Jul: mus_data_format_zero. * 12-Jul: mus_interp_type_p and mus_fft_window_p for C++'s benefit. * 1-July: mus-safety and various ints changed to mus_long_t. * 20-Jun: support for pthreads. * 16-Jun: changed init_mus_module to mus_initialize. * 30-May: changed polyshape to use cos and added cheby_choice arg to mus_make_polyshape. * 27-May: mus_waveshape retired -- generators.scm has a wrapper for it. * clm_free, clm_realloc etc for rt work. * mus_chebyshev_tu_sum. * 25-May: mus_polywave algorithm changed. * 17-May: mus_normalize_partials. * 12-Apr: added choice arg to mus_make_polywave. * 8-Apr: polywave uses sine-bank if highest harmonic out of Chebyshev range. * 1-Mar: mus_set_name. * 26-Feb: removed mus_cosines (use mus_length) * 24-Feb: removed mus_make_env_with_start, added mus_make_env_with_length * 20-Feb: clm 4: * polywave for polyshape and waveshape. * mus_formant_with_frequency. * firmant generator. * removed mus_formant_radius and mus_set_formant_radius. * removed "gain" arg from mus_make_formant. * reversed the order of the arguments to mus_make_formant. * fixed long-standing bug in gain calculation in mus_formant. * mus_env_any for arbitrary connecting functions. * 15-Feb: nrxysin and nrxycos for sine-summation. * 12-Feb: nsin for sum_of_sines, ncos for sum_of_cosines. * 4-Feb: clm_default_frequency (clm2xen) and *clm-default-frequency* (ws.scm). * 7-Jan-08: :dur replaced by :length in make-env. * -------- * 19-Oct: all *_0 *_1 *_2 names now use _fm|_pm|_unmodulated|_no_input. * 17-Oct: replace some method macros with functions (def-clm-struct local methods need true names). * 15-Oct: mus_oscil_1 -> _fm, _2->_pm. * mus_phase_vocoder_outctr accessors changed to use mus_location. * 11-Oct: changed default srate to 44100. * 5-Oct: mus_oscil_2. * 6-Sep: changed asymmetric-fm to use cos(sin) and added amplitude normalization. * 6-Aug: mus_autocorrelate, mus_correlate. * 3-Aug: blackman5..10 and Rife-Vincent (RV2..4 fft), mlt-sine windows. * 16-July: removed start arg from mus_make_env (see mus_make_env_with_start). * 5-July: changed some mus_float_ts to doubles in env funcs. * exp envs now use repeated multiplies rather than direct exp call. * 19-June: mus-increment on gens with a notion of frequency (phase increment); * to make room for this, asymmetric-fm ratio and sine-summation b moved to mus-offset. * 22-Feb: mus_big_fft and mus_spectrum_t. * 21-Feb: mus_fft_window_name. * 14-Feb-07: three more fft window choices. * -------- * 27-Nov: move-sound array access parallel to locsig. * 22-Nov: had to add non-backwards-compatible reverb chans arg to mus_make_locsig. * 21-Nov: mus_float_equal_fudge_factor, mus_arrays_are_equal. * 30-July: renamed average to moving_average. * 28-July: renamed make_ppolar and make_zpolar to make_two_pole|zero_from_radius_and_frequency. * added mus_scaler and mus_frequency methods for two_pole and two_zero. * 21-July: removed mus_wrapper field -- old way can't work since we need the original XEN object. * 3-July: mus_move_sound (dlocsig) generator. * changed return type of mus_locsig to float. * 28-June: mus_filtered_comb generator. * 8-May: mus_apply now takes 3 args: gen, two doubles (rather than bug-prone varargs). * 1-Mar-06: granulate now has a local random number seed (settable via the mus-location method). * -------- * 20-Dec: samaraki and ultraspherical windows. * this required a non-backwards-compatible additional argument in mus_make_fft_window_with_window. * 1-Nov: mus_filter_set_x|ycoeffs, mus_filter_set_order (needed by Snd). * 1-May: mus-scaler|feedback ok with delay and average. * 18-Apr: mus_set_environ. * 11-Apr: mus_mixer|frame_offset, mus_frame_scale (for higher level generic functions). * 23-Mar: frame_to_frame arg interpretation changed. * 21-Mar: mus_make_readin|file_to_sample|file_to_frame_with_buffer_size. * 16-Mar: polyshape generator (waveshaper as polynomial + oscil) * mus_chebyshev_first|second_kind. * mus_partials_to_waveshape no longer normalizes the partials. * 18-Feb: mus_interpolate. * 14-Feb: deprecated mus_restart_env and mus_clear_filter_state. * 7-Feb-05: mus_reset method, replaces mus_restart_env and mus_clear_filter_state. * -------- * 20-Dec: changed "jitter" handling if hop < .05 in granulate. * 15-Dec: mus_generator? for type checks (clm2xen). * 11-Sep: removed buffer generator. * 6-Sep: removed mus_oscil_bank, mus_bank. * 24-Aug: removed mus_inspect method -- overlaps mus_describe and is useless given gdb capabilities. * 27-July: mus_granulate_with_editor and mus_phase_vocoder_with_editors. * 21-July: edit-func as run-time arg to granulate (for CL/clm compatibility) * 19-July: clm 3: * deprecated mus_ina|b, mus-outa|b|c|d. * mus_make_frame_to_file_with_comment, mus_mixer_scale, mus_make_frame|mixer_with_data. * mus_make_scalar_mixer, mus_mixer_add, mus_continue_frame_to_file. * changed pv_* to phase_vocoder_* * 28-June: ssb_am + added fm arg (ssb_am_1 is the previous form). * 21-June: wrapper method. * 14-June: ssb_am generator. * deprecated mus-a*|b*, replaced by mus-x|ycoeff. * 9-June: mus_edot_product. * 7-June: removed mus-x*|y* generic functions. * 24-May: distribution arg to make-rand, make-rand-interp. * 11-May: type arg to mus_make_table_lookup|wave_train, MUS_INTERP_NONE, MUS_INTERP_HERMITE. * mus-interp-type. * 10-May: changed MUS_LINEAR and MUS_SINUSOIDAL to MUS_INTERP_LINEAR and MUS_INTERP_SINUSOIDAL. * mus-linear renamed mus-interp-linear, mus-sinusoidal renamed mus-interp-sinusoidal. * added type arg to mus_make_delay|all_pass|comb|notch. * added mus_delay_tick, all-pass delay line interpolation. * 3-May: envelope arg to make-rand and make-rand-interp to give any arbitrary random number distribution. * added mus_make_rand_with_distribution and mus_make_rand_interp_with_distribution. * rand/rand-interp mus-data returns distribution (weight) function, mus-length its length. * locsig mus-data returns output scalers, mus-xcoeffs returns reverb scalers * 26-Apr: mus_sum_of_sines changed to mus_sine_bank. * new mus_sum_of_sines parallels mus_sum_of_cosines. * deprecated mus_sin. * 14-Apr: changed "2" to "_to_" in several function names. * 12-Apr: mus_average, mus_average_p, mus_make_average. * 17-Mar: edit function added to mus_granulate. * replaced MUS_DATA_POSITION with MUS_DATA_WRAPPER. * 22-Jan: various "environ" variables renamed for Windows' benefit. * 5-Jan-04: env_interp bugfix. * -------- * 29-Sep: removed length arg from spectrum in clm2xen. * 24-Aug: changed mus_length|ramp|hop type to mus_long_t. * 21-Aug: export MUS_INPUT and friends (needed for specialized INA handlers). * 11-Aug: int -> bool. * 7-Aug: removed mus_type. * 20-July: more run methods. * 15-July: linear->dB check for 0.0 arg. * 27-June: mus_samples_to_seconds and mus_seconds_to_samples. * 9-June: mus_mix_with_reader_and_writer. * 27-May: bugfix: interpolating all-pass ("zall-pass") had an extra delay. * 25-Apr: mus_spectrum and mus_convolution now return mus_float_t*. * 9-Apr: removed MUS_HANNING_WINDOW (use MUS_HANN_WINDOW). * 3-Mar: mus_delay_line_p for tap error checking. * 27-Feb: mus_length for env -> original duration in samples. * 21-Feb: mus_set_cosines added, mus_cosines moved to hop slot. * mus_[set_]x1/x2/y1/y2. * 10-Feb: mus_file_name moved into the mus_input|output structs. * folded mus_input|output into mus_any. * moved mus_frame|mixer declarations into clm.c. * all mus_input|output|frame|mixer pointers->mus_any. * all method void pointers->mus_any. * 7-Feb: split strings out of clm2xen.c into clm-strings.h. * 3-Feb: mus_offset for envs, mus_width for square_wave et al. * new core class fields(10) for various methods. * 7-Jan-03: mus_src with very large sr_change segfault bugfix. * -------- * 17-Dec: mus_env_offset|initial_power for Snd exp env optimizations. * 13-Sep: mus_frandom and mus_irandom(for Snd optimizer). * 19-Aug: changed internal phase-vocoder array accessor names * 13-Aug: set!(*-ref) for frame, locsig, mixer, locsig-reverb. * 29-Jul: various *_1 cases for the optimizer. * 15-Jul: mus_continue_sample2file. * 10-Jul: mus_file_name. * 7-Jun: fftw support added. * 31-May: changed mus_any_class. * 3-May: many int->mus_long_t changes for large files. * 8-Apr: off-by-1 env bug(Lisp/C are now identical), env_interp of exp env beyond end bugfix. * 1-Apr: sine-summation n=0 bugfix. * 27-Mar: negative degree locsig bugfix. * 18-Mar: mus_move_locsig. * 15-Mar: n-chan locsig(and reverb scalers), 'type' arg to mus_make_locsig. * 6-Mar: mus_scaler in asymmetric-fm now refers to the "r" parameter, "a" in sine-summation. * 5-Mar: dumb typo in asymmetric-fm generator fixed. * 19-Feb: buffer reallocation redundant free bugfix. * 25-Jan-02: mus_increment of env returns base. * -------- * 10-Dec: add outctr calls, phase-vocoder bugfixes, thanks to <NAME>. * 21-Oct: fill in some set-data methods. * 1-Sep: mus_polar2rectangular. * 6-July: scm -> xen. * 26-May: mus_rand_seed. * 22-May: locsig reverb distance calc was upside down. * 18-May: mus_describe and mus_inspect returned string should not be freed any more. * 7-May: filled in some leftover equal_p methods. * 1-Apr: mus_make_file2sample_with_comment and mus_length for file->sample/sample->file. * mus_file_buffer_size. * 26-Mar: extended_type field added to mus_any_class for more robust type checking. * 16-Mar: mus_phase of env -> current_value. * 28-Feb: added mus_position(currently only for envs). * 8-Feb: clm2scm.h. * 24-Jan: mus-bank in clm2scm. * 5-Jan: clm2scm gens are applicable. * 4-Jan: mus_bank. * 2-Jan-01: mus_run method. * -------- * 28-Dec: mus_clear_filter_state and other minor tweaks for Snd. * 28-Nov: Dolph-Chebyshev window(under HAVE_GSL flag -- needs complex trig support). * 8-Nov: mus_clear_sinc_tables. * 12-Oct: mus_formant_bank takes one input(can't remember why I had an array here) * 27-Sep: mus_array_interp bugfix(imitates mus.lisp now). * 18-Sep: clm now assumes it's used as a part of sndlib. * 11-Sep: generalized set! to generic functions in clm2scm.c. * 31-Aug: changed formant field setters(thanks to <NAME>). * 10-Aug: removed built-in setf support(clm2scm.c). * 31-Jul: mus_granulate tries to protect against illegal length and ramp values. * 24-Jul: mus_make_fir_coeffs. * 20-Jul: sum_of_sines, atan2 to rectangular->polar, phase_vocoder gen. * 22-June: made mus_bessi0 local again. * 1-June: bugfixes for linuxppc 2000. * 19-May: mus_apply. * 8-May: added "const" and XEN_PROCEDURE_CAST(for c++), made mus_bessi0 global. * 24-Apr: changed formant radius to match lisp version(it's now 1-old_radius) * 20-Apr: mus_convolve_files * 7-Apr: src width bug fixed * 31-Mar: finally implemented set-location for envs. * 14-Feb: buffer-full?. * 1-Feb: removed mus_phasepartials2waveshape. * 3-Jan-00: format and type args added to make_sample2file, * mus_file_close. * removed make_file_input and make_file_output. * -------- * 29-Dec: various bugfixes especially in envelope handlers. * 19-Nov: mus_oscil_bank and mus_formant_bank. * 5-Nov: mus_sin exported. * 4-Oct:(scm) make-env arg order changed to reflect mus.lisp. * 29-Sep: implemented mus-increment and mus-frequency for granulate(as in mus.lisp). * clm's fft renamed mus-fft to avoid collision with snd's version. * added max_size arg to make_granulate(to reflect mus.lisp). * 25-Sep-99: added width arg to make_src -- forgot this somehow in first pass. * decided to make mus_inspect return char* like mus_describe. */
{'dir': 'c', 'id': '17726', 'max_stars_count': '1', 'max_stars_repo_name': 'SiddGururani/MUSI8903_Assignment_2', 'max_stars_repo_path': '3rdparty/sndlib/clm.h', 'n_tokens_mistral': 21856, 'n_tokens_neox': 20514, 'n_words': 4616}
const generatePins = async (modules) => { const { fs, request, csvDir, log, endpoint, stringify, order } = modules; var columns = {}; var pins = []; var lastPin = await request(endpoint); function random () { return Math.floor(1000000 + Math.random() * 9000000); }; function incrementString (string) { const toInt = +string + 1; return ('0000000' + toInt).slice(-7); }; function generate (lastPinArg, quantity) { let counter = lastPinArg.slice(-9).slice(0, 7); for (let i = 0; i < quantity; i++) { counter = incrementString(counter); let pin = `${random()}${counter}BH`; if (!pins[i]) { pins.push([pin]); } else { pins[i] = pins[i].concat([pin]); } }; lastPin = pins[pins.length - 1][0]; }; order.forEach((order, index) => { generate(lastPin, order.quantity); columns[`card${1 + index}`] = order.upc; }); stringify(pins, { columns, header: true }, (err, output) => { if (err) { console.log(err); } let dateStamp = (new Date()).toISOString().slice(0,10).replace(/-/g,""); fs.writeFileSync(`${csvDir}/${dateStamp}-pins.csv`, output); }); let orderTotal = order.reduce((prev, curr) => curr.quantity + prev.quantity); let message = `Successfully generated ${orderTotal} PINs.`; fs.appendFileSync(log, `${new Date().toString()} ${message}\n`); console.log(message); }; module.exports = { generatePins };
{'dir': 'javascript', 'id': '9697906', 'max_stars_count': '0', 'max_stars_repo_name': 'nhuesmann/blackhawk-pin-generator', 'max_stars_repo_path': 'bhn_generate_pins.js', 'n_tokens_mistral': 532, 'n_tokens_neox': 485, 'n_words': 107}
<gh_stars>0 // -------------------------------------------------------------------------------------------------------------------- // <copyright file="ProductDto.cs" company=""> // Copyright (c) 2013 <NAME>, for OrderDynamics coding test. All Rights Reserved. // </copyright> // -------------------------------------------------------------------------------------------------------------------- namespace WingtipToys.Core.Dtos { /// <summary> /// A data transfer object for Product. /// </summary> public class ProductDto { #region Public Properties /// <summary> /// Gets or sets the name of the category. /// </summary> /// <value> /// The name of the category. /// </value> public string CategoryName { get; set; } /// <summary> /// Gets or sets the search keywords. /// </summary> /// <value> /// The search keywords. /// </value> public string SearchKeywords { get; set; } #endregion } }
{'dir': 'c-sharp', 'id': '1001324', 'max_stars_count': '0', 'max_stars_repo_name': 'prototypev/coding-tests', 'max_stars_repo_path': 'WingtipToys/WingtipToys.Core/Dtos/ProductDto.cs', 'n_tokens_mistral': 240, 'n_tokens_neox': 236, 'n_words': 73}
const languageSelect = document.getElementById('languages') const sentenceInput = document.getElementById('text') const resultText = document.getElementById('stopwordsRemoved') function updateSentence() { const language = languageSelect.value const oldString = sentenceInput.value.split(' ') const newString = sw.removeStopwords(oldString, sw[language]).join(' ') console.group('Stopwords applied') console.log('oldString:', oldString.join(' ')) console.log('newString:', newString) console.groupEnd() // Populate with only meaningful words resultText.textContent = newString } // Listen to events and initiate a stopword removal sentenceInput.addEventListener('keyup', updateSentence) // Configure the language select const allLanguages = Object.entries(sw) .filter(([key, val]) => Array.isArray(val)) .map((val) => val[0]) languageSelect.addEventListener('change', function (event) { languageSelect.value = event.target.value sentenceInput.focus() updateSentence() }) languageSelect.innerHTML = allLanguages .map((lang) => `<option value=${lang}>${lang}</option>`) .join('') languageSelect.value = 'en'
{'dir': 'javascript', 'id': '10090297', 'max_stars_count': '176', 'max_stars_repo_name': 'joshmorenx/CitySends', 'max_stars_repo_path': 'blog/static/blog/stopword/demo/stopword-app.js', 'n_tokens_mistral': 324, 'n_tokens_neox': 321, 'n_words': 72}
<filename>src/Image Splitter.pyw<gh_stars>0 import sys from PyQt5 import QtWidgets, QtGui, QtCore from PyQt5.QtCore import * from PIL import Image from PIL.ImageQt import ImageQt font = QtGui.QFont("Arial", 12) def splitImage(filename, split_x, split_y, foldername, return_list = False): im = Image.open(filename) short_filename = filename.split('/')[-1] short_filename_no_ext = '.'.join(short_filename.split('.')[:-1]) file_ext = '.' + short_filename.split('.')[-1] images = list() for y in range(0, im.height, im.height // split_y): for x in range(0, im.width, im.width // split_x): cropped = im.crop((x, y, x + (im.width // split_x), y + (im.height // split_y))) images.append(cropped.copy()) if return_list: return images for i, im in enumerate(images): im.save(foldername + '/' + short_filename_no_ext + '_' + str(i) + file_ext) def calcScale(image_size, targetSize: tuple): w, h = image_size x_ratio = targetSize[0] / w y_ratio = targetSize[1] / h scale = x_ratio if y_ratio > x_ratio else y_ratio return scale class Window(QtWidgets.QWidget): def __init__(self): super().__init__() self.windowSize = (800, 600) self.imageMaxSize = (self.windowSize[0] * 0.6, self.windowSize[1] * 0.6) self.imageLoaded = False self.folderSelected = False self.setWindowTitle("Image Splitter") self.setGeometry(0, 0, self.windowSize[0], self.windowSize[1]) self.center() self.UI() self.show() self.timer = QtCore.QTimer(self) self.timer.setInterval(1) self.timer.timeout.connect(self.checkResized) self.timer.start() # Things would happen when window resized def checkResized(self): if self.width() * 0.6 != self.imageMaxSize[0] or self.height() * 0.6 != self.imageMaxSize[1]: self.windowSize = (self.width(), self.height()) self.imageMaxSize = (self.windowSize[0] * 0.6, self.windowSize[1] * 0.6) self.imagePreview.setMaximumSize(int(self.imageMaxSize[0]), int(self.imageMaxSize[1])) if self.imageLoaded: scale = calcScale(self.original_image.size, self.imageMaxSize) resized = (int(self.original_image.width * scale), int(self.original_image.height * scale)) self.pil_image = self.original_image.resize(resized, Image.ANTIALIAS) self.pil_image = self.pil_image.convert("RGBA") data = self.pil_image.tobytes('raw', 'RGBA') qim = QtGui.QImage(data, self.pil_image.size[0], self.pil_image.size[1], QtGui.QImage.Format_RGBA8888) self.imagePreview.setPixmap(QtGui.QPixmap.fromImage(qim)) self.drawStripes() # Open File Dialog def loadFile(self): self.filename = QtWidgets.QFileDialog.getOpenFileName(self, 'Open File', 'c:\\', "PNG files (*.png);;JPG files (*.jpg);;BMP files (*.bmp);;ICO files (*.ico)") if self.filename[0]: self.imageLoaded = True self.filename = self.filename[0] self.pil_image = Image.open(self.filename) self.original_image = self.pil_image.copy() scale = calcScale(self.pil_image.size, self.imageMaxSize) resized = (int(self.pil_image.width * scale), int(self.pil_image.height * scale)) self.pil_image = self.pil_image.resize(resized, Image.ANTIALIAS) self.pil_image = self.pil_image.convert("RGBA") data = self.pil_image.tobytes('raw', 'RGBA') qim = QtGui.QImage(data, self.pil_image.size[0], self.pil_image.size[1], QtGui.QImage.Format_RGBA8888) self.imagePreview.setPixmap(QtGui.QPixmap.fromImage(qim)) self.imagePreview.show() self.drawStripes() def drawStripes(self): if self.imageLoaded: im = self.pil_image.copy() pieceC = self.xSpinBox.value() pieceC = int(pieceC) per_pix = int(im.width / pieceC) for y in range(im.height): for x in range(per_pix, im.width, per_pix): pix = im.getpixel((x, y)) pix = (255 - pix[0], 255 - pix[1], 255 - pix[2], 255) im.putpixel((x, y), pix) pieceC = self.ySpinBox.value() pieceC = int(pieceC) per_pix = int(im.height / pieceC) for y in range(per_pix, im.height, per_pix): for x in range(im.width): if True: pix = im.getpixel((x, y)) pix = (255 - pix[0], 255 - pix[1], 255 - pix[2], 255) im.putpixel((x, y), pix) im = im.convert("RGBA") data = im.tobytes('raw', 'RGBA') qim = QtGui.QImage(data, im.size[0], im.size[1], QtGui.QImage.Format_RGBA8888) self.imagePreview.setPixmap(QtGui.QPixmap.fromImage(qim)) # Select Folder Dialog def selectFolder(self): file = str(QtWidgets.QFileDialog.getExistingDirectory(self, "Select Folder")) if file: self.folderSelected = True self.foldername = file def split(self): if self.imageLoaded and self.folderSelected: splitImage(self.filename, int(self.xSpinBox.value()), int(self.ySpinBox.value()), self.foldername) QtWidgets.QMessageBox.information(self, 'Operation Successfull!', 'Your image splitted successfully and saved to ' + self.foldername) else: QtWidgets.QMessageBox.critical(self, "Error!", "You must load an image and select a folder before splitting!") def makeGif(self): if self.imageLoaded and self.folderSelected: images = splitImage(self.filename, int(self.xSpinBox.value()), int(self.ySpinBox.value()), self.foldername, return_list=True) filename_no_ext = '.'.join(self.filename.split('/')[-1].split('.')[:-1]) images[0].save(self.foldername + '/' + filename_no_ext + '.gif', save_all=True, append_images=images[1:], optimize=False, loop=0, duration=40) QtWidgets.QMessageBox.information(self, 'Operation Successfull!', 'Your gif file created successfully and saved to ' + self.foldername) else: QtWidgets.QMessageBox.critical(self, "Error!", "You must load an image and select a folder before making gif!") def UI(self): # Layouts self.mainHLayout = QtWidgets.QHBoxLayout() self.mainVLayout = QtWidgets.QVBoxLayout() self.leftVLayout = QtWidgets.QVBoxLayout() self.rightVLayout = QtWidgets.QVBoxLayout() self.leftHLayout = QtWidgets.QHBoxLayout() self.rightHLayout = QtWidgets.QHBoxLayout() self.bottomHLayout = QtWidgets.QHBoxLayout() self.bottomVLayout = QtWidgets.QVBoxLayout() self.xAxisLayout = QtWidgets.QHBoxLayout() self.yAxisLayout = QtWidgets.QHBoxLayout() # Buttons self.selectFileButton = QtWidgets.QPushButton("Select File...") self.selectFileButton.setFont(font) self.selectFileButton.setMinimumSize(50, 40) self.selectFileButton.clicked.connect(self.loadFile) self.selectFolderButton = QtWidgets.QPushButton("Select Folder...") self.selectFolderButton.setFont(font) self.selectFolderButton.setMinimumSize(50, 40) self.selectFolderButton.clicked.connect(self.selectFolder) self.splitButton = QtWidgets.QPushButton("Split!") self.splitButton.setFont(font) self.splitButton.setMinimumSize(50, 40) self.splitButton.clicked.connect(self.split) self.makeGifButton = QtWidgets.QPushButton("Make Gif!") self.makeGifButton.setFont(font) self.makeGifButton.setMinimumSize(50, 40) self.makeGifButton.clicked.connect(self.makeGif) # Labels self.inputFileLabel = QtWidgets.QLabel(" Input File") self.inputFileLabel.setFont(font) self.outputFolderLabel = QtWidgets.QLabel(" Output Folder") self.outputFolderLabel.setFont(font) self.splitLabel_x = QtWidgets.QLabel("Split") self.splitLabel_x.setFont(font) self.splitLabel_y = QtWidgets.QLabel("Split") self.splitLabel_y.setFont(font) self.xAxisLabel = QtWidgets.QLabel("parts on x axis") self.xAxisLabel.setFont(font) self.yAxisLabel = QtWidgets.QLabel("parts on y axis") self.yAxisLabel.setFont(font) self.imagePreview = QtWidgets.QLabel() self.imagePreview.setMaximumSize(int(self.imageMaxSize[0]), int(self.imageMaxSize[1])) # Spin boxes self.xSpinBox = QtWidgets.QSpinBox() self.xSpinBox.setRange(1, 16) self.xSpinBox.setMaximumSize(50, 20) self.xSpinBox.valueChanged.connect(self.drawStripes) self.ySpinBox = QtWidgets.QSpinBox() self.ySpinBox.setRange(1, 16) self.ySpinBox.setMaximumSize(50, 20) self.ySpinBox.valueChanged.connect(self.drawStripes) # Design self.xAxisLayout.addWidget(self.splitLabel_x) self.xAxisLayout.addWidget(self.xSpinBox) self.xAxisLayout.addWidget(self.xAxisLabel) self.xAxisLayout.addStretch() self.yAxisLayout.addWidget(self.splitLabel_y) self.yAxisLayout.addWidget(self.ySpinBox) self.yAxisLayout.addWidget(self.yAxisLabel) self.yAxisLayout.addStretch() self.leftVLayout.addStretch() self.leftVLayout.addWidget(self.inputFileLabel) self.leftVLayout.addWidget(self.selectFileButton) self.leftVLayout.addStretch() self.leftVLayout.addLayout(self.xAxisLayout) self.leftVLayout.addLayout(self.yAxisLayout) self.leftVLayout.addStretch() self.leftVLayout.addWidget(self.outputFolderLabel) self.leftVLayout.addWidget(self.selectFolderButton) self.leftVLayout.addStretch() self.leftHLayout.addStretch() self.leftHLayout.addLayout(self.leftVLayout) self.leftHLayout.addStretch() self.rightVLayout.addStretch() self.rightVLayout.addWidget(self.imagePreview) self.rightVLayout.addStretch() self.rightHLayout.addStretch() self.rightHLayout.addLayout(self.rightVLayout) self.rightHLayout.addStretch() self.bottomHLayout.addStretch() self.bottomHLayout.addWidget(self.splitButton) self.bottomHLayout.addWidget(self.makeGifButton) self.bottomHLayout.addStretch() self.bottomVLayout.addStretch() self.bottomVLayout.addLayout(self.bottomHLayout) self.bottomVLayout.addStretch() self.mainHLayout.addLayout(self.leftHLayout) self.mainHLayout.addLayout(self.rightHLayout) self.mainVLayout.addLayout(self.mainHLayout) self.mainVLayout.addLayout(self.bottomVLayout) self.setLayout(self.mainVLayout) def center(self): qr = self.frameGeometry() cp = QtWidgets.QDesktopWidget().availableGeometry().center() qr.moveCenter(cp) self.move(qr.topLeft()) def main(): app = QtWidgets.QApplication(sys.argv) window = Window() sys.exit(app.exec_()) if __name__ == '__main__': main()
{'dir': 'python', 'id': '5249356', 'max_stars_count': '0', 'max_stars_repo_name': 'YunusEmre0037/Image-Splitter', 'max_stars_repo_path': 'src/Image Splitter.pyw', 'n_tokens_mistral': 3785, 'n_tokens_neox': 3588, 'n_words': 574}
<filename>src/components/Tables/Tables.tsx<gh_stars>0 import React, { useState } from 'react' import { columns as column } from './data/columns' const Tables =(props:any)=>{ const seller_data = props.sellerData; const buyer_data =props.buyerData; let sellerAndBuyerData:any = {...seller_data,...buyer_data} const [rows,setRows] = useState([ { id:'Add id', description:'Add description', unit:'Unit', quantity:'Quantity', unit_price:'Unit price', line:'Line total' }, ]) const handleChange =(index:any)=>{ if(index===rows.length-1){ let newRow = { id:'Add id', description:'Add description', unit:'Unit', quantity:'Quantity', unit_price:'Unit price', line:'Line total' }; let newRows = [...rows]; newRows.push(newRow); setRows(newRows); } } const print =()=>{ console.log(sellerAndBuyerData) const ipcRenderer = require("electron").ipcRenderer; const sellerName = sellerAndBuyerData.seller_name; const sellerTinNo = sellerAndBuyerData.tin_no const sellerAddress = sellerAndBuyerData.address const sellerSpecificAddress = sellerAndBuyerData.specific_addres const sellerPhone = sellerAndBuyerData.phone const fsno = sellerAndBuyerData.fsno; const date = sellerAndBuyerData.date const reference = sellerAndBuyerData.reference const bill_to = sellerAndBuyerData.bill_to const buyerTin = sellerAndBuyerData.buyer_tin_no // const buyerAddres = sellerAndBuyerData.buyer_address const content = [ { type: 'text', // 'text' | 'barCode' | 'qrCode' | 'image' | 'table value:`TIN: ${sellerTinNo}`, style: `text-align:center;`, css: {"font-size": "8px"} }, { type: 'text', // 'text' | 'barCode' | 'qrCode' | 'image' | 'table value:sellerName, style: `text-align:center;`, css: {"font-size": "12px"} }, { type: 'text', // 'text' | 'barCode' | 'qrCode' | 'image' | 'table value:sellerAddress, style: `text-align:center;`, css: {"font-size": "8px"} }, { type: 'text', // 'text' | 'barCode' | 'qrCode' | 'image' | 'table value:sellerSpecificAddress, style: `text-align:center;`, css: {"font-size": "8px"} }, { type: 'text', // 'text' | 'barCode' | 'qrCode' | 'image' | 'table value:sellerPhone, style: `text-align:center;`, css: {"font-size": "8px"} }, { type: 'text', // 'text' | 'barCode' | 'qrCode' | 'image' | 'table value:`FS NO.${fsno}`, style: `text-align:start;`, css: {"font-size": "8px"} }, { type: 'text', // 'text' | 'barCode' | 'qrCode' | 'image' | 'table value:date, style: `text-align:start;`, css: {"font-size": "8px"} }, { type: 'text', // 'text' | 'barCode' | 'qrCode' | 'image' | 'table value:'11:13', style: `text-align:end;`, css: {"font-size": "8px"} }, { type: 'text', // 'text' | 'barCode' | 'qrCode' | 'image' | 'table value:'# Cash sales invoice ', style: `text-align:start;`, css: {"font-size": "8px"} }, { type: 'text', // 'text' | 'barCode' | 'qrCode' | 'image' | 'table value:`# Reference ${reference}`, style: `text-align:start;`, css: {"font-size": "8px"} }, { type: 'text', // 'text' | 'barCode' | 'qrCode' | 'image' | 'table value:"# Prepared by: Ni", style: `text-align:start;`, css: {"font-size": "8px"} }, { type: 'text', // 'text' | 'barCode' | 'qrCode' | 'image' | 'table value:`# To: ${bill_to}`, style: `text-align:start;`, css: {"font-size": "8px"} }, { type: 'text', // 'text' | 'barCode' | 'qrCode' | 'image' | 'table value:`Buyer's TIN: ${buyerTin}`, style: `text-align:start;`, css: {"font-size": "8px","margin-bottom":"20px"} } ] let totalPrice:number =0.0; let taxPayment:number=0.0 let totalPayment:number=0.0 for(let i=0;i<rows.length-1;i++){ let descriptionValue = (document.getElementById(`description_${i}`) as HTMLInputElement).value; let quantityValue = (document.getElementById(`quantity_${i}`) as HTMLInputElement).value; let unitPriceValue = (document.getElementById(`unit_price_${i}`) as HTMLInputElement).value; let lineValue = (document.getElementById(`line_${i}`) as HTMLInputElement).value; let rowSummery = ` ${quantityValue} x ${unitPriceValue}` totalPrice +=parseInt(lineValue); content.push( { type: 'text', // 'text' | 'barCode' | 'qrCode' | 'image' | 'table value:rowSummery, style: 'margin-left:20px', css: {"font-size": "8px"} } ) content.push( { type: 'text', // 'text' | 'barCode' | 'qrCode' | 'image' | 'table value:`${descriptionValue} -------------------------------------------- ${lineValue.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",")}`, style: `text-align:start;`, css: {"font-size": "8px"} } ) } taxPayment = Math.round((15/100)*totalPrice); totalPayment = Math.round(totalPrice+taxPayment) content.push({ type: 'text', // 'text' | 'barCode' | 'qrCode' | 'image' | 'table value:"- - - -", style: 'text-align:center;margin-top:25px;', css: {"font-size": "8px"} }) content.push({ type: 'text', // 'text' | 'barCode' | 'qrCode' | 'image' | 'table value:`TXBL1 ---------------------------------------------${totalPrice.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",")}`, style: 'text-align:start;', css: {"font-size": "8px"} }) content.push({ type: 'text', // 'text' | 'barCode' | 'qrCode' | 'image' | 'table value:`TAX1 15% ---------------------------------${taxPayment.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",")}`, style: 'text-align:start;', css: {"font-size": "8px"} }) content.push({ type: 'text', // 'text' | 'barCode' | 'qrCode' | 'image' | 'table value:"- - - -", style: 'text-align:center;', css: {"font-size": "8px"} }) content.push({ type: 'text', // 'text' | 'barCode' | 'qrCode' | 'image' | 'table value:`Total -------------------------------${totalPayment.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",")}`, style: 'text-align:start;', css: {"font-size": "12px"} }) content.push({ type: 'text', // 'text' | 'barCode' | 'qrCode' | 'image' | 'table value:`# Cash -----------------------------------${totalPayment.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",")}`, style: 'text-align:start;', css: {"font-size": "8px"} }) content.push({ type: 'text', // 'text' | 'barCode' | 'qrCode' | 'image' | 'table value:"E R C A", style: 'text-align:center;', css: {"font-size": "8px"} }) content.push({ type: 'text', // 'text' | 'barCode' | 'qrCode' | 'image' | 'table value:"Powered by MarakiPOS 4.0", style: 'text-align:center;', css: {"font-size": "8px"} }) ipcRenderer.send("print", content); } const sumTotal =(index:number)=>{ let quantityValue = parseInt((document.getElementById(`quantity_${index}`) as HTMLInputElement).value); let unitPriceValue = parseInt((document.getElementById(`unit_price_${index}`) as HTMLInputElement).value); let lineTotalValue = quantityValue*unitPriceValue; (document.getElementById(`line_${index}`) as HTMLInputElement).value = lineTotalValue.toString(); } return <div> <table style={{borderCollapse:'collapse',width:'100%',border:'1px solid grey'}}> <tr style={{border:'1px solid grey'}}> { column.map(column=>( <th style={{border:'1px solid grey'}}>{column.label}</th> )) } </tr> <tbody> { rows.map((row,index)=>( ( <tr key={index} style={{border:'1px solid grey'}}> <td style={{border:'1px solid grey'}}> <input id={`id_${index}`} onFocus={()=>handleChange(index)} style={{width:'90%',padding:10}} placeholder={row.id}/> </td> <td style={{border:'1px solid grey'}}> <input id={`description_${index}`} style={{width:'90%',padding:10}} placeholder={row.description}/> </td> <td style={{border:'1px solid grey'}}> <input id={`unit_${index}`} style={{width:'90%',padding:10}} placeholder={row.unit}/> </td> <td style={{border:'1px solid grey'}}> <input id={`quantity_${index}`} style={{width:'90%',padding:10}} placeholder={row.quantity}/> </td> <td style={{border:'1px solid grey'}}> <input onChange={()=>sumTotal(index)} id={`unit_price_${index}`} style={{width:'90%',padding:10}} placeholder={row.unit_price}/> </td> <td style={{border:'1px solid grey'}}> <input id={`line_${index}`} style={{width:'90%',padding:10}} placeholder={row.line}/> </td> </tr> ) )) } </tbody> </table> <div style={{display:'flex',flexDirection:'row',justifyContent:'flex-end',padding:20}}> <button onClick={()=>print()} style={{backgroundColor:'green', color:'white',paddingTop:10,paddingBottom:10, paddingRight:50,paddingLeft:50}}> Print </button> </div> </div> } export default Tables
{'dir': 'typescript', 'id': '2608088', 'max_stars_count': '0', 'max_stars_repo_name': 'messyKassaye/electron-printer', 'max_stars_repo_path': 'src/components/Tables/Tables.tsx', 'n_tokens_mistral': 3425, 'n_tokens_neox': 3278, 'n_words': 593}
package com.jstappdev.e4client.ui; import android.annotation.SuppressLint; import android.graphics.Color; import android.os.Bundle; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.TextView; import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.fragment.app.Fragment; import androidx.lifecycle.LifecycleOwner; import androidx.lifecycle.Observer; import androidx.lifecycle.ViewModelProvider; import com.jstappdev.e4client.MainActivity; import com.jstappdev.e4client.R; import com.jstappdev.e4client.SharedViewModel; import com.jstappdev.e4client.data.E4SessionData; import com.jstappdev.e4client.util.Utils; import java.util.Locale; public class ConnectionFragment extends Fragment { private SharedViewModel sharedViewModel; private TextView accel_xLabel; private TextView accel_yLabel; private TextView accel_zLabel; private TextView bvpLabel; private TextView edaLabel; private TextView ibiLabel; private TextView hrLabel; private TextView temperatureLabel; private TextView batteryLabel; private TextView statusLabel; private TextView deviceNameLabel; private TextView wristStatusLabel; private View dataArea; private String microsiemens; private String celsius; @SuppressLint("SourceLockedOrientationActivity") public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { sharedViewModel = new ViewModelProvider(requireActivity()).get(SharedViewModel.class); final View root = inflater.inflate(R.layout.fragment_connection, container, false); final TextView textView = root.findViewById(R.id.status); sharedViewModel.getSessionStatus().observe(getViewLifecycleOwner(), new Observer<String>() { @Override public void onChanged(@Nullable String s) { textView.setText(s); } }); return root; } @Override public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) { statusLabel = view.findViewById(R.id.status); accel_xLabel = view.findViewById(R.id.accel_x); accel_yLabel = view.findViewById(R.id.accel_y); accel_zLabel = view.findViewById(R.id.accel_z); bvpLabel = view.findViewById(R.id.bvp); edaLabel = view.findViewById(R.id.eda); ibiLabel = view.findViewById(R.id.ibi); hrLabel = view.findViewById(R.id.hr); temperatureLabel = view.findViewById(R.id.temperature); batteryLabel = view.findViewById(R.id.battery); deviceNameLabel = view.findViewById(R.id.deviceName); wristStatusLabel = view.findViewById(R.id.wrist_status_label); dataArea = view.findViewById(R.id.dataArea); microsiemens = getString(R.string.microsiemens); celsius = getString(R.string.celsius); view.findViewById(R.id.disconnectButton).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { ((MainActivity) requireContext()).disconnect(); dataArea.setVisibility(View.GONE); ((MainActivity) requireContext()).openFragment(R.id.nav_home); } }); //noinspection ConstantConditions if (!sharedViewModel.getIsConnected().getValue()) { ((MainActivity) requireContext()).initEmpaticaDeviceManager(); } } @Override public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); final LifecycleOwner owner = getViewLifecycleOwner(); sharedViewModel.getIsConnected().observe(owner, new Observer<Boolean>() { @Override public void onChanged(Boolean isConnected) { if (isConnected) { dataArea.setVisibility(View.VISIBLE); E4SessionData.clear(); E4SessionData.getInstance().setInitialTime(Utils.getCurrentTimestamp()); } else { dataArea.setVisibility(View.GONE); } } }); sharedViewModel.getDeviceName().observe(owner, new Observer<String>() { @Override public void onChanged(String deviceName) { deviceNameLabel.setText(deviceName); } }); sharedViewModel.getSessionStatus().observe(owner, new Observer<String>() { @Override public void onChanged(String status) { statusLabel.setText(status); } }); sharedViewModel.getOnWrist().observe(owner, new Observer<Boolean>() { @Override public void onChanged(Boolean onWrist) { wristStatusLabel.setText(onWrist ? "ON WRIST" : "NOT ON WRIST"); } }); sharedViewModel.getBattery().observe(owner, new Observer<Float>() { @Override public void onChanged(Float battery) { batteryLabel.setText(String.format(Locale.getDefault(), "%.0f %%", battery * 100)); } }); sharedViewModel.getCurrentAccX().observe(owner, new Observer<Integer>() { public void onChanged(Integer accX) { accel_xLabel.setText(accX.toString()); } }); sharedViewModel.getCurrentAccY().observe(owner, new Observer<Integer>() { public void onChanged(Integer accY) { accel_yLabel.setText(accY.toString()); } }); sharedViewModel.getCurrentAccZ().observe(owner, new Observer<Integer>() { public void onChanged(Integer accZ) { accel_zLabel.setText(accZ.toString()); } }); sharedViewModel.getCurrentGsr().observe(owner, new Observer<Float>() { @Override public void onChanged(Float gsr) { edaLabel.setText(String.format(Locale.getDefault(), "%.2f %s", gsr, microsiemens)); } }); sharedViewModel.getCurrentIbi().observe(owner, new Observer<Float>() { @Override public void onChanged(Float ibi) { ibiLabel.setText(String.format(Locale.getDefault(), "%.2f s", ibi)); } }); sharedViewModel.getCurrentHr().observe(owner, new Observer<Float>() { @Override public void onChanged(Float averageHr) { hrLabel.setText(String.format(Locale.getDefault(), "%.0f BPM", averageHr)); } }); sharedViewModel.getCurrentTemp().observe(owner, new Observer<Float>() { @Override public void onChanged(Float temp) { temperatureLabel.setText(String.format(Locale.getDefault(), "%.2f %s", temp, celsius)); } }); sharedViewModel.getCurrentBvp().observe(owner, new Observer<Float>() { int count = 0; @Override public void onChanged(Float bvp) { if (count++ % 10 == 0) bvpLabel.setText(String.format(Locale.getDefault(), "%.0f", bvp)); } }); } }
{'dir': 'java', 'id': '3234122', 'max_stars_count': '0', 'max_stars_repo_name': 'j05t/e4client', 'max_stars_repo_path': 'app/src/main/java/com/jstappdev/e4client/ui/ConnectionFragment.java', 'n_tokens_mistral': 2061, 'n_tokens_neox': 1919, 'n_words': 346}
<gh_stars>0 import React, { ChangeEvent, Component, createRef } from 'react'; import FormCheckboxGroup from '../../components/form/FormCheckboxGroup'; import { RadioChangeEventHandler } from '../../components/form/FormRadio'; import FormRadioGroup from '../../components/form/FormRadioGroup'; import PageHeading from '../../components/PageHeading'; import Tabs from '../../components/Tabs'; import TabsSection from '../../components/TabsSection'; import PrototypePage from '../components/PrototypePage'; import PrototypeAbsenceGeneralChart from './charts/PrototypeAbsenceGeneralChart'; import PrototypeAbsenceRateChart from './charts/PrototypeAbsenceRateChart'; import PrototypeFixedPeriodExclusionsChart from './charts/PrototypeFixedPeriodExclusionsChart'; import PrototypePermanentExclusionsChart from './charts/PrototypePermanentExclusionsChart'; import PublicationMenu, { MenuChangeEventHandler, MenuOption, } from './components/PublicationMenu'; import { allTableData as exclusionTableData } from './test-data/exclusionsDataV1'; import { allTableData as absenceTableData } from './test-data/pupilAbsenceDataV1'; type DataToggles = 'CHARTS_TABLES' | 'CHARTS' | 'TABLES' | null; const allTableData: any = { exclusions: exclusionTableData, pupilAbsence: absenceTableData, }; type PupilAbsenceGeneralFilters = 'enrolments' | 'schools'; type PupilAbsenceSessionsFilters = | 'authorisedRate' | 'overallRate' | 'unauthorisedRate'; type ExclusionsExclusionsFilters = | 'permanent' | 'permanentRate' | 'fixedPeriod' | 'fixedPeriodRate'; interface State { chartData: { [key: string]: number; }[]; dataToggle: DataToggles; menuOption?: MenuOption | null; filters: { exclusions: { exclusions: { [key in ExclusionsExclusionsFilters]: boolean }; }; pupilAbsence: { general: { [key in PupilAbsenceGeneralFilters]: boolean }; sessions: { [key in PupilAbsenceSessionsFilters]: boolean }; }; }; tableData: string[][]; } class PrototypeDataTableV2 extends Component<{}, State> { public state: State = { chartData: [], dataToggle: null, filters: { exclusions: { exclusions: { fixedPeriod: false, fixedPeriodRate: false, permanent: false, permanentRate: false, }, }, pupilAbsence: { general: { enrolments: false, schools: false, }, sessions: { authorisedRate: false, overallRate: false, unauthorisedRate: false, }, }, }, menuOption: null, tableData: [], }; private dataTableRef = createRef<HTMLDivElement>(); private handleMenuChange: MenuChangeEventHandler = menuOption => { this.setState( { menuOption, filters: { exclusions: { exclusions: { fixedPeriod: false, fixedPeriodRate: false, permanent: false, permanentRate: false, }, }, pupilAbsence: { general: { enrolments: false, schools: false, }, sessions: { authorisedRate: false, overallRate: false, unauthorisedRate: false, }, }, }, tableData: [], }, () => { if (this.dataTableRef.current) { this.dataTableRef.current.scrollIntoView({ behavior: 'smooth' }); } }, ); }; private createTableData(filters: {}) { return Object.entries(filters).flatMap(([publicationKey, publication]) => { return Object.entries(publication) .flatMap(([groupKey, group]) => { return Object.entries(group) .filter(([_, isChecked]) => isChecked) .map(([filterKey]) => { return allTableData[publicationKey][groupKey][filterKey]; }); }) .filter(row => row.length > 0); }); } private handleAllFilterCheckboxChange = ( publicationKey: 'pupilAbsence' | 'exclusions', filterGroupKey: 'exclusions' | 'general' | 'sessions', event: ChangeEvent<HTMLInputElement>, ) => { const filterGroup = this.state.filters[publicationKey] as any; const subFilterGroup = filterGroup[filterGroupKey]; const filters = { ...this.state.filters, [publicationKey]: { ...filterGroup, [filterGroupKey]: Object.keys(subFilterGroup).reduce((acc, key) => { return { ...acc, [key]: event.target.checked, }; }, {}), }, }; this.setState({ filters, tableData: this.createTableData(filters), }); }; private handleFilterCheckboxChange = ( publicationKey: 'pupilAbsence' | 'exclusions', filterGroupKey: 'exclusions' | 'general' | 'sessions', event: ChangeEvent<HTMLInputElement>, ) => { const filterGroup = this.state.filters[publicationKey] as any; const subFilterGroup = filterGroup[filterGroupKey]; const filters = { ...this.state.filters, [publicationKey]: { ...filterGroup, [filterGroupKey]: { ...subFilterGroup, [event.target.value]: event.target.checked, }, }, }; this.setState({ filters, tableData: this.createTableData(filters), }); }; private handleRadioChange: RadioChangeEventHandler<{ value: DataToggles; }> = event => { this.setState({ dataToggle: event.target.value }); }; private hasSessionsFilters() { return ( Object.values(this.state.filters.pupilAbsence.sessions).indexOf(true) > -1 ); } private hasGeneralFilters() { return ( Object.values(this.state.filters.pupilAbsence.general).indexOf(true) > -1 ); } private hasPermanentExclusionFilters() { return ( this.state.filters.exclusions.exclusions.permanent || this.state.filters.exclusions.exclusions.permanentRate ); } private hasFixedPeriodExclusionFilters() { return ( this.state.filters.exclusions.exclusions.fixedPeriod || this.state.filters.exclusions.exclusions.fixedPeriodRate ); } private hasAnyFilters() { return Object.values(this.state.filters).map(filterGroup => Object.values(filterGroup).some(filter => filter.size > 0), ); } private getFilterValues(filters: { [key: string]: boolean }) { return Object.entries(filters) .filter(([_, isChecked]) => isChecked) .map(([key]) => key); } public render() { const { filters } = this.state; return ( <PrototypePage breadcrumbs={[ { text: 'Education training and skills' }, { text: 'National level' }, { text: 'Explore statistics' }, ]} wide > <PageHeading caption="National level" heading="Explore statistics" /> <ul> <li> You can explore all the DfE statistics available at national level here. </li> <li> Once you've chosen your data you can view it by year, school type, area or pupil characteristics. </li> <li> You can also download it, visualise it or copy and paste it as you need. </li> </ul> <div className="govuk-grid-row"> <div className="govuk-grid-column-full"> <PublicationMenu onChange={this.handleMenuChange} /> </div> </div> {(this.state.menuOption === 'EXCLUSIONS' || this.state.menuOption === 'PUPIL_ABSENCE') && ( <div ref={this.dataTableRef}> {this.state.menuOption === 'PUPIL_ABSENCE' && ( <h2> 2. Explore statistics from 'Pupil absence' <span className="govuk-hint"> Select any statistics you are interested in from the checkboxes below </span> </h2> )} {this.state.menuOption === 'EXCLUSIONS' && ( <h2> 2. Explore statistics from 'Exclusions' <span className="govuk-hint"> Select any statistics you are interested in from the checkboxes below </span> </h2> )} <div className="govuk-grid-row"> <div className="govuk-grid-column-one-quarter"> {this.state.menuOption === 'PUPIL_ABSENCE' && ( <> <div className="govuk-form-group"> <FormCheckboxGroup value={this.getFilterValues( this.state.filters.pupilAbsence.general, )} name="pupilAbsenceGeneral" id="pupilAbsenceGeneral" legend="General" onAllChange={this.handleAllFilterCheckboxChange.bind( this, 'pupilAbsence', 'general', )} onChange={this.handleFilterCheckboxChange.bind( this, 'pupilAbsence', 'general', )} options={[ { id: 'general-enrolments', label: 'Enrolments', value: 'enrolments', }, { id: 'general-schools', label: 'Schools', value: 'schools', }, ]} /> </div> <div className="govuk-form-group"> <FormCheckboxGroup value={this.getFilterValues( this.state.filters.pupilAbsence.sessions, )} name="pupilAbsenceSessions" id="pupilAbsenceSessions" legend="Sessions absent" onAllChange={this.handleAllFilterCheckboxChange.bind( this, 'pupilAbsence', 'sessions', )} onChange={this.handleFilterCheckboxChange.bind( this, 'pupilAbsence', 'sessions', )} options={[ { id: 'sessions-authorised-rate', label: 'Authorised rate', value: 'authorisedRate', }, { id: 'sessions-overall-rate', label: 'Overall rate', value: 'overallRate', }, { id: 'sessions-unauthorised-rate', label: 'Unauthorised rate', value: 'unauthorisedRate', }, ]} /> </div> </> )} {this.state.menuOption === 'EXCLUSIONS' && ( <FormCheckboxGroup value={this.getFilterValues( this.state.filters.exclusions.exclusions, )} name="exclusions" id="exclusions" legend="Exclusions" onAllChange={this.handleAllFilterCheckboxChange.bind( this, 'exclusions', 'exclusions', )} onChange={this.handleFilterCheckboxChange.bind( this, 'exclusions', 'exclusions', )} options={[ { id: 'permanent-exclusions', label: 'Permanent exclusions', value: 'permanent', }, { id: 'permanent-exclusions-rate', label: 'Permanent exclusion rate', value: 'permanentRate', }, { id: 'fixed-period-exclusions', label: 'Fixed period exclusions', value: 'fixedPeriod', }, { id: 'fixed-period-exclusions-rate', label: 'Fixed period exclusion rate', value: 'fixedPeriodRate', }, ]} /> )} </div> {this.hasAnyFilters() && ( <div className="govuk-grid-column-three-quarters"> <FormRadioGroup value={this.state.dataToggle} inline id="dataToggle" name="dataToggle" legend="What do you want to see?" legendSize="m" onChange={this.handleRadioChange as any} options={[ { id: 'chartsAndTable', label: 'Charts and table', value: 'CHARTS_TABLES', }, { id: 'charts', label: 'Charts', value: 'CHARTS' }, { id: 'table', label: 'Table', value: 'TABLES' }, ]} /> {this.state.dataToggle && ( <> <p>View by:</p> <Tabs> <TabsSection id="years" title="Academic years"> <> {(this.state.dataToggle === 'CHARTS_TABLES' || this.state.dataToggle === 'CHARTS') && ( <div className="govuk-grid-row"> {this.state.menuOption === 'PUPIL_ABSENCE' && ( <> {this.hasGeneralFilters() && ( <div className="govuk-grid-column-one-half"> <p>General</p> <PrototypeAbsenceGeneralChart enrolments={ filters.pupilAbsence.general .enrolments } schools={ filters.pupilAbsence.general.schools } /> </div> )} {this.hasSessionsFilters() && ( <div className="govuk-grid-column-one-half"> <p>Sessions absent</p> <PrototypeAbsenceRateChart authorised={ filters.pupilAbsence.sessions .authorisedRate } unauthorised={ filters.pupilAbsence.sessions .unauthorisedRate } overall={ filters.pupilAbsence.sessions .overallRate } /> </div> )} </> )} {this.state.menuOption === 'EXCLUSIONS' && ( <> {this.hasPermanentExclusionFilters() && ( <div className="govuk-grid-column-one-half"> <p>Permanent exclusions</p> <PrototypePermanentExclusionsChart exclusions={ filters.exclusions.exclusions .permanent } exclusionsRate={ filters.exclusions.exclusions .permanentRate } /> </div> )} {this.hasFixedPeriodExclusionFilters() && ( <div className="govuk-grid-column-one-half"> <p>Fixed period exclusions</p> <PrototypeFixedPeriodExclusionsChart exclusions={ filters.exclusions.exclusions .fixedPeriod } exclusionsRate={ filters.exclusions.exclusions .fixedPeriodRate } /> </div> )} </> )} </div> )} {this.hasAnyFilters() && ( <> <hr /> {(this.state.dataToggle === 'CHARTS_TABLES' || this.state.dataToggle === 'TABLES') && ( <table className="govuk-table"> <caption> Comparing statistics between 2012 and 2017 </caption> <thead> <tr> <th /> <th scope="col">2012/13</th> <th scope="col">2013/14</th> <th scope="col">2014/15</th> <th scope="col">2015/16</th> <th scope="col">2016/17</th> </tr> </thead> <tbody> {this.state.tableData.map( ([firstCell, ...cells], rowIndex) => ( <tr key={rowIndex}> <td scope="row">{firstCell}</td> {cells.map((cell, cellIndex) => ( <td key={cellIndex}>{cell}</td> ))} </tr> ), )} </tbody> </table> )} <ul className="govuk-list"> <li> <a href="#download">Download data (.csv)</a> </li> <li> <a href="#api">Access developer API</a> </li> <li> <a href="#methodology">Methodology</a> </li> <li> <a href="#contact">Contact</a> </li> </ul> </> )} </> </TabsSection> <TabsSection id="school-type" title="School type"> {null} </TabsSection> <TabsSection id="geography" title="Geography"> {null} </TabsSection> <TabsSection id="demographics-characteristics" title="Demographics/characteristics" > {null} </TabsSection> </Tabs> </> )} </div> )} </div> </div> )} </PrototypePage> ); } } export default PrototypeDataTableV2;
{'dir': 'typescript', 'id': '1471650', 'max_stars_count': '0', 'max_stars_repo_name': 'markhiveit/explore-education-statistics', 'max_stars_repo_path': 'src/explore-education-statistics-frontend/src/prototypes/data-table/PrototypeDataTableV2.tsx', 'n_tokens_mistral': 5007, 'n_tokens_neox': 4698, 'n_words': 812}
/** * Provides a wrapper to interact with the security configuration */ var jenkins = require('../util/jenkins'); /** * Calls a stapler post method to save the first user settings */ exports.saveFirstUser = function($form, success, error) { jenkins.staplerPost( '/setupWizard/createAdminUser', $form, function(response) { var crumbRequestField = response.data.crumbRequestField; if (crumbRequestField) { require('window-handle').getWindow().crumb.init(crumbRequestField, response.data.crumb); } success(response); }, { error: error }); }; exports.saveConfigureInstance = function($form, success, error){ jenkins.staplerPost( '/setupWizard/configureInstance', $form, function(response) { var crumbRequestField = response.data.crumbRequestField; if (crumbRequestField) { require('window-handle').getWindow().crumb.init(crumbRequestField, response.data.crumb); } success(response); }, { error: error }); }; /** * Calls a stapler post method to save the first user settings */ exports.saveProxy = function($form, success, error) { jenkins.staplerPost( '/pluginManager/proxyConfigure', $form, success, { dataType: 'html', error: error }); };
{'dir': 'javascript', 'id': '2916345', 'max_stars_count': '637', 'max_stars_repo_name': '1st/jenkins', 'max_stars_repo_path': 'war/src/main/js/api/securityConfig.js', 'n_tokens_mistral': 438, 'n_tokens_neox': 385, 'n_words': 82}
<reponame>The-Graphe-A-Design-Studio/member-directory<filename>app/Http/Controllers/api/v1/user/UserController.php <?php namespace App\Http\Controllers\api\v1\user; use App\Http\Controllers\Controller; use Illuminate\Support\Facades\Storage; use Illuminate\Support\Facades\Auth; use Illuminate\Http\Request; use App\User; use Validator; class UserController extends Controller { /** * Display a listing of the resource. * * @return \Illuminate\Http\Response */ public function index() { return User::all(); } /** * Show the form for creating a new resource. * * @return \Illuminate\Http\Response */ public function create() { // } /** * Store a newly created resource in storage. * * @param \Illuminate\Http\Request $request * @return \Illuminate\Http\Response */ public function store(Request $request) { // } /** * Display the specified resource. * * @param int $id * @return \Illuminate\Http\Response */ public function show($id) { // } /** * Show the form for editing the specified resource. * * @param int $id * @return \Illuminate\Http\Response */ public function edit($id) { // } /** * Update the specified resource in storage. * * @param \Illuminate\Http\Request $request * @param int $id * @return \Illuminate\Http\Response */ public function update(Request $request) { $user = Auth::user(); $rules = [ 'IM_no' => 'nullable|regex:/^[A-Za-z0-9 ]+$/', 'name' => 'nullable|regex:/^[A-Za-z ]+$/', 'dob' => 'nullable|date', 'phone' => 'nullable|unique:users|min:10|max:10|regex:/^[0-9]+$/', 'email' => 'nullable|unique:users|email', 'password' => 'nullable|regex:/^[A-Za-z0-9 ]+$/', 'gender' => 'nullable|in:Male,Female,Others', 'photo' => 'nullable|mimes:jpg,jpeg,png', 'club_name' => 'nullable|regex:/^[A-Za-z0-9 ]+$/', 'designation' => 'nullable|regex:/^[A-Za-z0-9 ]+$/', 'occupation' => 'nullable|regex:/^[A-Za-z0-9 ]+$/', 'blood_group' => 'nullable|in:A+,A-,B+,B-,O+,O-,AB+,AB-', 'sponsorer' => 'nullable|regex:/^[A-Za-z0-9 ]+$/', ]; $validator = Validator::make($request->all(), $rules); if($validator->fails()){ return response()->json($validator->errors(), 400); } if($request->hasFile('photo')) { //delete old visiting card if exists if($user->photo != null){ // $storage = "/home/thegrhmw/public_html/developers/flexy/storage/app/visiting_card/"; // $storage = "storage/app/profile_pic/"; // $path = $storage . $user->photo; $storage = Storage::disk('local')->getAdapter()->getPathPrefix(); $path = $storage . "profile_pic/" . $user->photo; unlink($path); // unlink($user->photo); } //add the new image $file = $request->file('photo'); //Get file name with the extension $fileNameWithExt = $file->getClientOriginalName(); //Get just Filename $filename = pathinfo($fileNameWithExt, PATHINFO_FILENAME); //Get just Extension $extension = $file->getClientOriginalExtension(); // Filename to store $fileNameToStore = $filename.'_'.time().'.'.$extension; Storage::disk('local')->putFileAs('profile_pic', $request->file('photo'), $fileNameToStore); } $user->IM_no = ( empty($request->get('IM_no')) ) ? $user->IM_no : $request->get('IM_no'); $user->name = ( empty($request->get('name')) ) ? $user->name : $request->get('name'); $user->dob = ( empty($request->get('dob')) ) ? $user->dob : $request->get('dob'); $user->phone = ( empty($request->get('phone')) ) ? $user->phone : $request->get('phone'); $user->email = ( empty($request->get('email')) ) ? $user->email : $request->get('email'); $user->gender = ( empty($request->get('gender')) ) ? $user->gender : $request->get('gender'); $user->photo = ( empty($fileNameToStore) ) ? $user->photo : $fileNameToStore; $user->club_name = ( empty($request->get('club_name')) ) ? $user->club_name : $request->get('club_name'); $user->designation = ( empty($request->get('designation')) ) ? $user->designation : $request->get('designation'); $user->occupation = ( empty($request->get('occupation')) ) ? $user->occupation : $request->get('occupation'); $user->blood_group = ( empty($request->get('blood_group')) ) ? $user->blood_group : $request->get('blood_group'); $user->save(); return response()->json(['status' => 'success', 'messege' => 'Member details updated'], 200); } /** * Remove the specified resource from storage. * * @param int $id * @return \Illuminate\Http\Response */ public function destroy($id) { // } public function search(Request $request) { $term = $request->input('term'); $members = User::where('name', 'LIKE', '%'.$term.'%') ->orWhere('club_name', 'LIKE', '%'.$term.'%') ->orWhere('designation', 'LIKE', '%'.$term.'%') ->orWhere('occupation', 'LIKE', '%'.$term.'%') ->orWhere('IM_no', 'LIKE', '%'.$term.'%')->get(); if(!empty($members)) { return response()->json(['status' => 'success', 'members' => $members], 200); } return response()->json(['status' => 'success', 'message' => 'No members found'], 200); } public function getleos(Request $request) { $leos = User::where('leo', 1)->get(); return response()->json(['status' => 'success', 'members' => $leos], 200); } }
{'dir': 'php', 'id': '11521909', 'max_stars_count': '0', 'max_stars_repo_name': 'The-Graphe-A-Design-Studio/member-directory', 'max_stars_repo_path': 'app/Http/Controllers/api/v1/user/UserController.php', 'n_tokens_mistral': 1927, 'n_tokens_neox': 1879, 'n_words': 318}
<reponame>adityaagassi/ympimisdev <!DOCTYPE html> <html> <head> <title>YMPI 情報システム</title> <!-- <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> --> <meta charset="UTF-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta content="width=device-width, user-scalable=yes, initial-scale=1.0" name="viewport"> <style type="text/css"> body{ font-size: 10px; } #isi > thead > tr > td { text-align: center; } #isi > tbody > tr > td { text-align: left; padding-left: 5px; } * { font-family: arial; } .page-break { page-break-after: always; } @page { } .footer { position: fixed; left: 0px; bottom: 100px; right: 0px; height: 130px;text-align: center;} .footer .pagenum:before { content: counter(page); } </style> </head> <body> <header> <table style="width: 100%; font-family: arial; border-collapse: collapse; text-align: left;"> <thead> <tr> <td colspan="12" style="font-weight: bold;font-size: 13px">PT. YAMAHA MUSICAL PRODUCTS INDONESIA</td> </tr> <tr> <td colspan="12"><br></td> </tr> <tr> <td colspan="3">&nbsp;</td> <td colspan="6" style="text-align: center;font-weight: bold;font-size: 16px">PURCHASE REQUISITION FORM</td> <td colspan="2" style="text-align: right;font-size: 12px">No:</td> <td colspan="1" style="text-align: right;font-size: 14px;font-weight: bold">{{ $pr[0]->no_pr }}</td> </tr> <tr> <td colspan="12"><br></td> </tr> <tr> <td colspan="2" style="font-size: 12px;width: 22%">Department</td> <td colspan="10" style="font-size: 12px;">: {{ $pr[0]->department }}</td> </tr> <tr> <td colspan="2" style="font-size: 12px;width: 22%">Section</td> @if($pr[0]->section != null) <td colspan="10" style="font-size: 12px;">: {{ $pr[0]->section }}</td> @else <td colspan="10" style="font-size: 12px;">: {{ $pr[0]->department }}</td> @endif </tr> <tr> <td colspan="2" style="font-size: 12px;width: 22%">Date Of Submission</td> <td colspan="10" style="font-size: 12px;">: <?= date('d-M-Y', strtotime($pr[0]->submission_date)) ?></td> </tr> <tr> <td colspan="2" style="font-size: 12px;width: 22%">Budget</td> <td colspan="10" style="font-size: 12px;">: {{ $pr[0]->no_budget }}</td> </tr> <tr> <td colspan="12"><br></td> </tr> </thead> </table> </header> @if($pr[0]->receive_date != null) <img width="120" src="{{ public_path() . '/files/ttd_pr_po/received.jpg' }}" alt="" style="padding: 0;position: absolute;top: 55px;left: 840px"> <span style="position: absolute;width: 100px;font-size: 12px;font-weight: bold;font-family: arial-narrow;top:88px;left: 875px;color:#c34354"><?= date('d-M-y', strtotime($pr[0]->receive_date)) ?></span> @endif <main> <table style="width: 100%; font-family: arial; border-collapse: collapse; " id="isi"> <thead> <tr style="font-size: 12px"> <td colspan="1" style="padding:10px;height: 15px; width:1%; background-color: #03a9f4; font-weight: bold; border: 1px solid black;">No</td> <td colspan="1" style="width:3%; background-color: #03a9f4; font-weight: bold; border: 1px solid black;">Item Code</td> <td colspan="3" style="width:8%; background-color: #03a9f4; font-weight: bold; border: 1px solid black;">Description</td> <td colspan="1" style="width:4%; background-color: #03a9f4; font-weight: bold; border: 1px solid black;">Request Date</td> <td colspan="1" style="width:2%; background-color: #03a9f4; font-weight: bold; border: 1px solid black;">Qty</td> <td colspan="1" style="width:3%; background-color: #03a9f4; font-weight: bold; border: 1px solid black;">Currency</td> <td colspan="1" style="width:3%; background-color: #03a9f4; font-weight: bold; border: 1px solid black;">Unit Price</td> <td colspan="2" style="width:3%; background-color: #03a9f4; font-weight: bold; border: 1px solid black;">Amount</td> <td colspan="1" style="width:4%; background-color: #03a9f4; font-weight: bold; border: 1px solid black;">Last Order</td> </tr> </thead> <tbody> <?php $no = 1; $totalidr = 0; foreach($pr as $purchase_r) { if($purchase_r->item_currency == "IDR"){ $totalidr += $purchase_r->item_amount; } if ($no % 15 == 0) { ?> <tr> <td colspan="1" style="height: 26px; border: 1px solid black;text-align: center;padding: 0">{{ $no }}</td> <td colspan="1" style="border: 1px solid black;">{{ $purchase_r->item_code }}</td> <td colspan="3" style="border: 1px solid black;"> {{ $purchase_r->item_desc }} </td> <!-- <td clolspan="1" style="border: 1px solid black;">{{ $purchase_r->item_stock }}</td> --> <td colspan="1" style="border: 1px solid black;text-align: right;padding-right: 5px"><?= date('d-M-y', strtotime($purchase_r->item_request_date)) ?></td> <td colspan="1" style="border: 1px solid black;">{{ $purchase_r->item_qty }} {{ $purchase_r->item_uom }}</td> <td colspan="1" style="border: 1px solid black;">{{ $purchase_r->item_currency }}</td> @if($purchase_r->item_currency == "IDR") <td colspan="1" style="border: 1px solid black;text-align: right;padding-right: 5px"><?= number_format($purchase_r->item_price,0,"",".") ?></td> @else <td colspan="1" style="border: 1px solid black;text-align: right;padding-right: 5px"><?= $purchase_r->item_price ?></td> @endif @if($purchase_r->item_currency == "IDR") <td colspan="2" style="border: 1px solid black;text-align: right;padding-right: 5px"><?= number_format($purchase_r->item_amount,0,"",".") ?></td> @else <td colspan="2" style="border: 1px solid black;text-align: right;padding-right: 5px"><?= $purchase_r->item_amount ?></td> @endif <td colspan="1" style="border: 1px solid black;"> @if($purchase_r->last_order != null) <?= date('d-M-Y', strtotime($purchase_r->last_order)) ?> @else - @endif </td> </tr> </tbody> </table> <footer> <div class="footer"> <table style="width: 100%;font-family: arial;border-collapse: collapse;"> <tr> <th colspan="3" style="background-color: #4caf50; border: 1px solid black;font-size: 12px;text-align: center;font-weight: bold">Summary Total PR</th> <th colspan="1"></th> <th colspan="3" style="background-color: yellow; border: 1px solid black;font-size: 12px;text-align: center;font-weight: bold">Budget Detail</th> </tr> <tr> <th colspan="1" style="background-color: #4caf50; border: 1px solid black;font-size: 12px;text-align: center;">Currency</th> <th colspan="1" style="background-color: #4caf50; border: 1px solid black;font-size: 12px;text-align: center;">Amount (Original)</th> <th colspan="1" style="background-color: #4caf50; border: 1px solid black;font-size: 12px;text-align: center;">Amount (US$)</th> <th colspan="1"></th> <th colspan="1" style="background-color:yellow; font-size: 12px;text-align:center; padding:10px; height: 15px; font-weight: bold; border: 1px solid black;">Beg Balance</th> <th colspan="1" style="background-color:yellow; font-size: 12px;text-align:center; padding:10px; height: 15px; font-weight: bold; border: 1px solid black;">Amount</th> <th colspan="1" style="background-color:yellow; font-size: 12px;text-align:center; padding:10px; height: 15px; font-weight: bold; border: 1px solid black;">End Balance</th> </tr> <tr> <td colspan="1" rowspan="2" style="border: 1px solid black;font-size: 12px;text-align: center;">IDR</td> <td colspan="1" rowspan="2" style="border: 1px solid black;font-size: 12px;text-align: center;">Rp. <?= number_format($totalidr,0,"",".") ?></td> <td colspan="1" rowspan="2" style="border: 1px solid black;font-size: 12px;text-align: center;"> <?php $totalkonversiidr = $totalidr / $rate[0]->rate; ?> $ <?= number_format($totalkonversiidr,0,".","") ?> </td> <th colspan="1" rowspan="2"></th> <?php $totalamount = 0; foreach ($pr as $pr_budget) { $totalamount += $pr_budget->amount; } ?> <td colspan="1" rowspan="2" style="text-align:center; font-size:14px; font-weight: bold; padding:5px; height: 15px; border: 1px solid black;">$ <?= number_format($pr[0]->beg_bal,0,".","") ?></td> <td colspan="1" rowspan="2" style="text-align:center; font-size:14px; font-weight: bold; padding:5px; height: 15px; border: 1px solid black;">$ <?= number_format($totalamount,0,".","") ?></td> <td colspan="1" rowspan="2" style="text-align:center; font-weight: bold;font-size:14px; padding:5px; height: 15px; border: 1px solid black;">$ <?= number_format($pr[0]->beg_bal - $totalamount,0,".","") ?></td> </tr> <tr> </tr> <tr> <td colspan="7"> &nbsp;</td> </tr> </table> <table style="width: 100%; font-family: arial; border-collapse: collapse; text-align: center;" border="1"> <thead> <tr> <td colspan="1" style="width:15%;height: 26px; border: 1px solid black;text-align: center;padding: 0">Applied By</td> <td colspan="1" style="width:15%;">Acknowledge By</td> <td colspan="1" style="width:15%;">Approve By</td> <td colspan="6" rowspan="3" style="text-align: left;padding: 5px;vertical-align: top;font-size: 11px"> Note : @if($pr[0]->note == null) - @else <br><?= $pr[0]->note ?> @endif </td> </tr> </thead> <tbody> <tr> <td colspan="1" style="height: 40px"> @if($pr[0]->posisi != "staff") <?= $pr[0]->emp_name ?> @endif </td> <td colspan="1" style="height: 40px"> @if($pr[0]->approvalm == "Approved") <?= $pr[0]->manager_name ?> @endif </td> <td colspan="1" style="height: 40px"> @if($pr[0]->approvalgm == "Approved" && $pr[0]->gm == "PI1206001") <img width="70" src="{{ public_path() . '/files/ttd_pr_po/stempel_pak_hayakawa.jpg' }}" alt="" style="padding: 0"> <span style="position: absolute;left: 227px;width: 75px;font-size: 8px;color: #f84c32;top: 165px;font-family: arial-narrow"><?= date('d F Y', strtotime($pr[0]->dateapprovalgm)) ?></span> @elseif($pr[0]->approvalgm == "Approved" && $pr[0]->gm == "PI9709001") <img width="70" src="{{ public_path() . '/files/ttd_pr_po/stempel_pak_arief.jpg' }}" alt="" style="padding: 0"> <span style="position: absolute;left: 227px;width: 75px;font-size: 8px;color: #f84c32;top: 165px;font-family: arial-narrow"><?= date('d F Y', strtotime($pr[0]->dateapprovalgm)) ?></span> @elseif($pr[0]->approvalgm == "Approved" && $pr[0]->gm == "PI0109004") <img width="70" src="{{ public_path() . '/files/ttd_pr_po/stempel_pak_budhi.jpg' }}" alt="" style="padding: 0"> <span style="position: absolute;left: 227px;width: 75px;font-size: 8px;color: #f84c32;top: 165px;font-family: arial-narrow"><?= date('d F Y', strtotime($pr[0]->dateapprovalgm)) ?></span> @endif </td> </tr> <tr> <td colspan="1">User</td> <td colspan="1">Manager</td> <td colspan="1">Director</td> </tr> </tbody> </table> Page <span class="pagenum"></span> </div> </footer> <div class="page-break"></div> <header> <table style="width: 100%; font-family: arial; border-collapse: collapse; text-align: left;"> <thead> <tr> <td colspan="12" style="font-weight: bold;font-size: 13px">PT. YAMAHA MUSICAL PRODUCTS INDONESIA</td> </tr> <tr> <td colspan="12"><br></td> </tr> <tr> <td colspan="3">&nbsp;</td> <td colspan="6" style="text-align: center;font-weight: bold;font-size: 16px">PURCHASE REQUISITION FORM</td> <td colspan="2" style="text-align: right;font-size: 12px">No:</td> <td colspan="1" style="text-align: right;font-size: 14px;font-weight: bold">{{ $pr[0]->no_pr }}</td> </tr> <tr> <td colspan="12"><br></td> </tr> <tr> <td colspan="2" style="font-size: 12px;width: 22%">Department</td> <td colspan="10" style="font-size: 12px;">: {{ $pr[0]->department }}</td> </tr> <tr> <td colspan="2" style="font-size: 12px;width: 22%">Section</td> @if($pr[0]->section != null) <td colspan="10" style="font-size: 12px;">: {{ $pr[0]->section }}</td> @else <td colspan="10" style="font-size: 12px;">: {{ $pr[0]->department }}</td> @endif </tr> <tr> <td colspan="2" style="font-size: 12px;width: 22%">Date Of Submission</td> <td colspan="10" style="font-size: 12px;">: <?= date('d-M-Y', strtotime($pr[0]->submission_date)) ?></td> </tr> <tr> <td colspan="2" style="font-size: 12px;width: 22%">Budget</td> <td colspan="10" style="font-size: 12px;">: {{ $pr[0]->no_budget }}</td> </tr> <tr> <td colspan="12"><br></td> </tr> </thead> </table> </header> @if($pr[0]->receive_date != null) <img width="120" src="{{ public_path() . '/files/ttd_pr_po/received.jpg' }}" alt="" style="padding: 0;position: absolute;top: 55px;left: 840px"> <span style="position: absolute;width: 100px;font-size: 12px;font-weight: bold;font-family: arial-narrow;top:88px;left: 875px;color:#c34354"><?= date('d-M-y', strtotime($pr[0]->receive_date)) ?></span> @endif <table style="width: 100%; font-family: arial; border-collapse: collapse; " id="isi"> <thead> <tr style="font-size: 12px"> <td colspan="1" style="padding:10px;height: 15px; width:1%; background-color: #03a9f4; font-weight: bold; border: 1px solid black;">No</td> <td colspan="1" style="width:3%; background-color: #03a9f4; font-weight: bold; border: 1px solid black;">Item Code</td> <td colspan="3" style="width:8%; background-color: #03a9f4; font-weight: bold; border: 1px solid black;">Description</td> <!-- <td colspan="1" style="width:2%; background-color: #03a9f4; font-weight: bold; border: 1px solid black;">Stock WIP</td> --> <td colspan="1" style="width:4%; background-color: #03a9f4; font-weight: bold; border: 1px solid black;">Request Date</td> <td colspan="1" style="width:2%; background-color: #03a9f4; font-weight: bold; border: 1px solid black;">Qty</td> <td colspan="1" style="width:3%; background-color: #03a9f4; font-weight: bold; border: 1px solid black;">Currency</td> <td colspan="1" style="width:3%; background-color: #03a9f4; font-weight: bold; border: 1px solid black;">Unit Price</td> <td colspan="2" style="width:3%; background-color: #03a9f4; font-weight: bold; border: 1px solid black;">Amount</td> <td colspan="1" style="width:4%; background-color: #03a9f4; font-weight: bold; border: 1px solid black;">Last Order</td> </tr> </thead> <tbody> <?php } else { ?> <tr> <td colspan="1" style="height: 26px; border: 1px solid black;text-align: center;padding: 0">{{ $no }}</td> <td colspan="1" style="border: 1px solid black;">{{ $purchase_r->item_code }}</td> <td colspan="3" style="border: 1px solid black;"> {{ $purchase_r->item_desc }} </td> <!-- <td clolspan="1" style="border: 1px solid black;">{{ $purchase_r->item_stock }}</td> --> <td colspan="1" style="border: 1px solid black;text-align: right;padding-right: 5px"><?= date('d-M-y', strtotime($purchase_r->item_request_date)) ?></td> <td colspan="1" style="border: 1px solid black;">{{ $purchase_r->item_qty }} {{ $purchase_r->item_uom }}</td> <td colspan="1" style="border: 1px solid black;">{{ $purchase_r->item_currency }}</td> @if($purchase_r->item_currency == "IDR") <td colspan="1" style="border: 1px solid black;text-align: right;padding-right: 5px"><?= number_format($purchase_r->item_price,0,"",".") ?></td> @else <td colspan="1" style="border: 1px solid black;text-align: right;padding-right: 5px"><?= $purchase_r->item_price ?></td> @endif @if($purchase_r->item_currency == "IDR") <td colspan="2" style="border: 1px solid black;text-align: right;padding-right: 5px"><?= number_format($purchase_r->item_amount,0,"",".") ?></td> @else <td colspan="2" style="border: 1px solid black;text-align: right;padding-right: 5px"><?= $purchase_r->item_amount ?></td> @endif <td colspan="1" style="border: 1px solid black;"> @if($purchase_r->last_order != null) <?= date('d-M-Y', strtotime($purchase_r->last_order)) ?> @else - @endif </td> </tr> <?php } ?> <?php $no++; } ?> <tr> <td colspan="12">&nbsp;</td> </tr> </tbody> </table> </main> <footer> <div class="footer"> <table style="width: 100%;font-family: arial;border-collapse: collapse;"> <tr> <th colspan="3" style="background-color: #4caf50; border: 1px solid black;font-size: 12px;text-align: center;font-weight: bold">Summary Total PR</th> <th colspan="1"></th> <th colspan="3" style="background-color: yellow; border: 1px solid black;font-size: 12px;text-align: center;font-weight: bold">Budget Detail</th> </tr> <tr> <th colspan="1" style="background-color: #4caf50; border: 1px solid black;font-size: 12px;text-align: center;">Currency</th> <th colspan="1" style="background-color: #4caf50; border: 1px solid black;font-size: 12px;text-align: center;">Amount (Original)</th> <th colspan="1" style="background-color: #4caf50; border: 1px solid black;font-size: 12px;text-align: center;">Amount (US$)</th> <th colspan="1"></th> <th colspan="1" style="background-color:yellow; font-size: 12px;text-align:center; padding:10px; height: 15px; font-weight: bold; border: 1px solid black;">Beg Balance</th> <th colspan="1" style="background-color:yellow; font-size: 12px;text-align:center; padding:10px; height: 15px; font-weight: bold; border: 1px solid black;">Amount</th> <th colspan="1" style="background-color:yellow; font-size: 12px;text-align:center; padding:10px; height: 15px; font-weight: bold; border: 1px solid black;">End Balance</th> </tr> <tr> <td colspan="1" rowspan="2" style="border: 1px solid black;font-size: 12px;text-align: center;">IDR</td> <td colspan="1" rowspan="2" style="border: 1px solid black;font-size: 12px;text-align: center;">Rp. <?= number_format($totalidr,0,"",".") ?></td> <td colspan="1" rowspan="2" style="border: 1px solid black;font-size: 12px;text-align: center;"> <?php $totalkonversiidr = $totalidr / $rate[0]->rate; ?> $ <?= number_format($totalkonversiidr,0,".","") ?> </td> <th colspan="1" rowspan="2"></th> <?php $totalamount = 0; foreach ($pr as $pr_budget) { $totalamount += $pr_budget->amount; } ?> <td colspan="1" rowspan="2" style="text-align:center; font-size:14px; font-weight: bold; padding:5px; height: 15px; border: 1px solid black;">$ <?= number_format($pr[0]->beg_bal,0,".","") ?></td> <td colspan="1" rowspan="2" style="text-align:center; font-size:14px; font-weight: bold; padding:5px; height: 15px; border: 1px solid black;">$ <?= number_format($totalamount,0,".","") ?></td> <td colspan="1" rowspan="2" style="text-align:center; font-weight: bold;font-size:14px; padding:5px; height: 15px; border: 1px solid black;">$ <?= number_format($pr[0]->beg_bal - $totalamount,0,".","") ?></td> </tr> <tr> </tr> <tr> <td colspan="7"> &nbsp;</td> </tr> </table> <table style="width: 100%; font-family: arial; border-collapse: collapse; text-align: center;" border="1"> <thead> <tr> <td colspan="1" style="width:15%;height: 26px; border: 1px solid black;text-align: center;padding: 0">Applied By</td> <td colspan="1" style="width:15%;">Acknowledge By</td> <td colspan="1" style="width:15%;">Approve By</td> <td colspan="6" rowspan="3" style="text-align: left;padding: 5px;vertical-align: top;font-size: 11px"> Note : @if($pr[0]->note == null) - @else <br><?= $pr[0]->note ?> @endif </td> </tr> </thead> <tbody> <tr> <td colspan="1" style="height: 40px"> @if($pr[0]->posisi != "staff") <?= $pr[0]->emp_name ?> @endif </td> <td colspan="1" style="height: 40px"> @if($pr[0]->approvalm == "Approved") <?= $pr[0]->manager_name ?> @endif </td> <td colspan="1" style="height: 40px"> @if($pr[0]->approvalgm == "Approved" && $pr[0]->gm == "PI1206001") <img width="70" src="{{ public_path() . '/files/ttd_pr_po/stempel_pak_hayakawa.jpg' }}" alt="" style="padding: 0"> <span style="position: absolute;left: 227px;width: 75px;font-size: 8px;color: #f84c32;top: 165px;font-family: arial-narrow"><?= date('d F Y', strtotime($pr[0]->dateapprovalgm)) ?></span> @elseif($pr[0]->approvalgm == "Approved" && $pr[0]->gm == "PI9709001") <img width="70" src="{{ public_path() . '/files/ttd_pr_po/stempel_pak_arief.jpg' }}" alt="" style="padding: 0"> <span style="position: absolute;left: 227px;width: 75px;font-size: 8px;color: #f84c32;top: 165px;font-family: arial-narrow"><?= date('d F Y', strtotime($pr[0]->dateapprovalgm)) ?></span> @elseif($pr[0]->approvalgm == "Approved" && $pr[0]->gm == "PI0109004") <img width="70" src="{{ public_path() . '/files/ttd_pr_po/stempel_pak_budhi.jpg' }}" alt="" style="padding: 0"> <span style="position: absolute;left: 227px;width: 75px;font-size: 8px;color: #f84c32;top: 165px;font-family: arial-narrow"><?= date('d F Y', strtotime($pr[0]->dateapprovalgm)) ?></span> @endif </td> </tr> <tr> <td colspan="1">User</td> <td colspan="1">Manager</td> <td colspan="1">Director</td> </tr> </tbody> </table> Page <span class="pagenum"></span> </div> </footer> </body> </html>
{'dir': 'php', 'id': '6257201', 'max_stars_count': '1', 'max_stars_repo_name': 'adityaagassi/ympimisdev', 'max_stars_repo_path': 'resources/views/general_affairs/report/report_pr.blade.php', 'n_tokens_mistral': 11114, 'n_tokens_neox': 8133, 'n_words': 1692}
<?php namespace Cruxinator\ClassFinder\Tests; use Composer\Autoload\ClassLoader; use Cruxinator\ClassFinder\ClassFinder; use ReflectionClass; use ReflectionProperty; /** * Class ClassFinderConcrete. * @property bool classLoaderInit * @property null|array optimisedClassMap * @property array loadedNamespaces * @property string vendorDir * @package Tests\Cruxinator\ClassFinder * @method array getProjectClasses(string $namespace) * @method array getClassMap(string $namespace) * @method bool strStartsWith($needle, $haystack) * @method void checkState() * @method void initClassMap() * @method array getClasses(string $namespace = '',callable $conditional = null, bool $includeVendor = true) * @method array getProjectSearchDirs(string $namespace) * @method bool isClassInVendor(string $className) * @method ClassLoader getComposerAutoloader() * @method string getVendorDir() * @method array findCompatibleNamespace(string $namespace, array $psr4) */ class ClassFinderConcrete extends ClassFinder { public function __construct() { $this->loadedNamespaces = []; $this->optimisedClassMap = null; $this->vendorDir = ''; $this->classLoaderInit = false; } /** * @param $name * @throws \ReflectionException * @return \ReflectionMethod */ protected static function getMethod($name) { $class = new ReflectionClass(self::class); $method = $class->getMethod($name); $method->setAccessible(true); return $method; } /** * @param $name * @throws \ReflectionException * @return ReflectionProperty */ protected static function getProperty($name) { $reflectionProperty = new ReflectionProperty(parent::class, $name); $reflectionProperty->setAccessible(true); return $reflectionProperty; } /** * @param $name * @param $arguments * @throws \ReflectionException * @return mixed */ public function __call($name, $arguments) { $method = self::getMethod($name); return $method->invokeArgs(null, $arguments); } /** * @param $name * @param $value * @throws \ReflectionException */ public function __set($name, $value) { $property = self::getProperty($name); $property->setValue(null, $value); } /** * @param $name * @throws \ReflectionException */ public function __get($name) { $property = self::getProperty($name); return $property->getValue(); } }
{'dir': 'php', 'id': '12353032', 'max_stars_count': '0', 'max_stars_repo_name': 'cruxinator/ClassFinder', 'max_stars_repo_path': 'tests/ClassFinderConcrete.php', 'n_tokens_mistral': 726, 'n_tokens_neox': 728, 'n_words': 165}
import nock from 'nock'; import path from 'path'; import { fetchCsvBasedTimeline } from './fetch-timeline'; const TESTDATA_DIR = path.resolve(__dirname, '..', '..', 'testdata'); describe('fetchCsvBasedTimeSeries', () => { beforeEach(() => { nock( 'https://raw.githubusercontent.com/CSSEGISandData/COVID-19/master/csse_covid_19_data/csse_covid_19_time_series', ) .get('/time_series_covid19_confirmed_global.csv') .replyWithFile(200, path.join(TESTDATA_DIR, 'confirmed.csv')) .get('/time_series_covid19_deaths_global.csv') .replyWithFile(200, path.join(TESTDATA_DIR, 'deceased.csv')) .get('/time_series_covid19_recovered_global.csv') .replyWithFile(200, path.join(TESTDATA_DIR, 'recovered.csv')); nock('https://raw.githubusercontent.com/lukes/ISO-3166-Countries-with-Regional-Codes/master/all') .get('/all.csv') .replyWithFile(200, path.join(TESTDATA_DIR, 'all.csv')); }); it('works', async () => { try { const result = await fetchCsvBasedTimeline(); expect(result).toMatchSnapshot(); } catch (err) { fail(err); } }); });
{'dir': 'typescript', 'id': '4893254', 'max_stars_count': '8', 'max_stars_repo_name': 'svandriel/covid19-graphql', 'max_stars_repo_path': 'src/fetching/fetch-timeline.spec.ts', 'n_tokens_mistral': 424, 'n_tokens_neox': 398, 'n_words': 48}
<div class="row"> <div class="col-xs-12"> <?php $location_widget_activated = osc_get_preference('show-locations', 'frclassifieds'); ?> <?php $contry_code = get_user_country_code(); if($contry_code !=''){ $code = $contry_code; }else{ $code = 0; } ?> <?php if($location_widget_activated=!'' && $location_widget_activated == 'activated'){?> <?php if(osc_count_list_regions($code) > 0 ) { ?> <div class="box location"> <ul> <?php while(osc_has_list_regions() ) { ?> <li><a class="btn btn-outlined btn-sm btn-transparent-theme <?php if(get_region_location() == osc_list_region_name() ){ echo 'active'; }?>" href="<?php echo osc_list_region_url(); ?>"><?php echo osc_list_region_name() ; ?> <em>(<?php echo osc_list_region_items() ; ?>)</em></a></li> <?php } ?> </ul> </div> <?php } ?> <?php } ?> </div> </div>
{'dir': 'php', 'id': '12189493', 'max_stars_count': '0', 'max_stars_repo_name': 'EloneSampaio/classificado-da-fronteira', 'max_stars_repo_path': 'oc-content/themes/frclassifieds/inc/locations.php', 'n_tokens_mistral': 369, 'n_tokens_neox': 328, 'n_words': 57}
<filename>trackme/lib/py2/past/__init__.py # coding=utf-8 """ past: compatibility with Python 2 from Python 3 =============================================== ``past`` is a package to aid with Python 2/3 compatibility. Whereas ``future`` contains backports of Python 3 constructs to Python 2, ``past`` provides implementations of some Python 2 constructs in Python 3 and tools to import and run Python 2 code in Python 3. It is intended to be used sparingly, as a way of running old Python 2 code from Python 3 until the code is ported properly. Potential uses for libraries: - as a step in porting a Python 2 codebase to Python 3 (e.g. with the ``futurize`` script) - to provide Python 3 support for previously Python 2-only libraries with the same APIs as on Python 2 -- particularly with regard to 8-bit strings (the ``past.builtins.str`` type). - to aid in providing minimal-effort Python 3 support for applications using libraries that do not yet wish to upgrade their code properly to Python 3, or wish to upgrade it gradually to Python 3 style. Here are some code examples that run identically on Python 3 and 2:: >>> from past.builtins import str as oldstr >>> philosopher = oldstr(u'\u5b54\u5b50'.encode('utf-8')) >>> # This now behaves like a Py2 byte-string on both Py2 and Py3. >>> # For example, indexing returns a Python 2-like string object, not >>> # an integer: >>> philosopher[0] '\xe5' >>> type(philosopher[0]) <past.builtins.oldstr> >>> # List-producing versions of range, reduce, map, filter >>> from past.builtins import range, reduce >>> range(10) [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] >>> reduce(lambda x, y: x+y, [1, 2, 3, 4, 5]) 15 >>> # Other functions removed in Python 3 are resurrected ... >>> from past.builtins import execfile >>> execfile('myfile.py') >>> from past.builtins import raw_input >>> name = raw_input('What is your name? ') What is your name? [cursor] >>> from past.builtins import reload >>> reload(mymodule) # equivalent to imp.reload(mymodule) in Python 3 >>> from past.builtins import xrange >>> for i in xrange(10): ... pass It also provides import hooks so you can import and use Python 2 modules like this:: $ python3 >>> from past.translation import autotranslate >>> authotranslate('mypy2module') >>> import mypy2module until the authors of the Python 2 modules have upgraded their code. Then, for example:: >>> mypy2module.func_taking_py2_string(oldstr(b'abcd')) Credits ------- :Author: <NAME> :Sponsor: Python Charmers Pty Ltd, Australia: http://pythoncharmers.com Licensing --------- Copyright 2013-2018 Python Charmers Pty Ltd, Australia. The software is distributed under an MIT licence. See LICENSE.txt. """ from future import __version__, __copyright__, __license__ __title__ = 'past' __author__ = '<NAME>'
{'dir': 'python', 'id': '4057288', 'max_stars_count': '1', 'max_stars_repo_name': 'duanshuaimin/trackme', 'max_stars_repo_path': 'trackme/lib/py2/past/__init__.py', 'n_tokens_mistral': 935, 'n_tokens_neox': 838, 'n_words': 369}
<filename>src/main/java/br/rickcm/transacaoapp/TransacaoAppApplication.java package br.rickcm.transacaoapp; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.cloud.openfeign.EnableFeignClients; import org.springframework.data.jpa.repository.config.EnableJpaRepositories; @SpringBootApplication @EnableFeignClients @EnableJpaRepositories(enableDefaultTransactions = false) public class TransacaoAppApplication { public static void main(String[] args) { SpringApplication.run(TransacaoAppApplication.class, args); } }
{'dir': 'java', 'id': '5469851', 'max_stars_count': '0', 'max_stars_repo_name': 'rick-cm/desafio-transacao', 'max_stars_repo_path': 'src/main/java/br/rickcm/transacaoapp/TransacaoAppApplication.java', 'n_tokens_mistral': 183, 'n_tokens_neox': 180, 'n_words': 25}
<reponame>JetBrains/teamcity-vmware-plugin<gh_stars>10-100 /* * Copyright 2000-2021 JetBrains s.r.o. * * 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 jetbrains.buildServer.clouds.vmware.connector; import com.vmware.vim25.LocalizedMethodFault; import com.vmware.vim25.TaskInfo; import com.vmware.vim25.TaskInfoState; import com.vmware.vim25.mo.Task; import java.util.Date; import java.util.concurrent.Callable; import java.util.concurrent.atomic.AtomicBoolean; import jetbrains.buildServer.clouds.base.connector.AsyncCloudTask; import jetbrains.buildServer.clouds.base.connector.CloudTaskResult; import jetbrains.buildServer.log.LogUtil; import jetbrains.buildServer.util.impl.Lazy; import org.jetbrains.annotations.NotNull; /** * @author Sergey.Pak * Date: 7/29/2014 * Time: 6:22 PM */ public class VmwareTaskWrapper implements AsyncCloudTask { private final Callable<Task> myVmwareTask; private final String myTaskName; private volatile long myStartTime; private final Lazy<CloudTaskResult> myResultLazy; private final AtomicBoolean myIsDone = new AtomicBoolean(false); public VmwareTaskWrapper(@NotNull final Callable<Task> vmwareTask, String taskName){ myVmwareTask = vmwareTask; myTaskName = taskName; myResultLazy = new Lazy<CloudTaskResult>() { @Override protected CloudTaskResult createValue() { try { myStartTime = System.currentTimeMillis(); return getResult(myVmwareTask.call()); } catch (Exception e) { return createErrorTaskResult(e); } finally { myIsDone.set(true); } } }; } @Override public CloudTaskResult executeOrGetResult() { return myResultLazy.getValue(); } @NotNull public String getName() { return myTaskName; } public long getStartTime() { return myStartTime; } @Override public boolean isDone() { return myIsDone.get(); } @NotNull private CloudTaskResult getResult(final Task task) { try { final String result = task.waitForTask(); final TaskInfo taskInfo = task.getTaskInfo(); if (taskInfo.getState() == TaskInfoState.error){ final LocalizedMethodFault error = taskInfo.getError(); return new CloudTaskResult(true, result, new Exception(error== null ? "Unknown error" : error.getLocalizedMessage())); } else { return new CloudTaskResult(result); } } catch (Exception e) { return new CloudTaskResult(true, e.toString(), e); } } private CloudTaskResult createErrorTaskResult(Exception e){ return new CloudTaskResult(true, e.toString(), e); } @Override public String toString() { return "VmwareTaskWrapper{" + "TaskName='" + myTaskName + '\'' + ",StartTime=" + LogUtil.describe(new Date(myStartTime)) + '}'; } }
{'dir': 'java', 'id': '3108380', 'max_stars_count': '17', 'max_stars_repo_name': 'JetBrains/teamcity-vmware-plugin', 'max_stars_repo_path': 'cloud-vmware-server/src/main/java/jetbrains/buildServer/clouds/vmware/connector/VmwareTaskWrapper.java', 'n_tokens_mistral': 1023, 'n_tokens_neox': 978, 'n_words': 260}
<filename>chapter_004/src/test/java/ru/job4j/list/DynamicArrayTest.java<gh_stars>0 package ru.job4j.list; import org.hamcrest.core.Is; import org.junit.Before; import org.junit.Test; import java.util.ConcurrentModificationException; import java.util.Iterator; import static org.hamcrest.Matchers.is; import static org.junit.Assert.assertThat; /** * DynamicArrayTest. * @author <NAME> * @since 04.05.2018 * @version 1.0 */ public class DynamicArrayTest { /** Container. */ private DynamicArray<Integer> list; /** * Customize tests. */ @Before public void beforeTest() { list = new DynamicArray<>(); list.add(1); list.add(2); list.add(3); } /** * Test for get method. */ @Test public void whenAddThreeElementsThenUseGetOneResultTwo() { assertThat(list.get(1), is(2)); } /** * Iterator Testing. */ @Test public void whenIteratorThanIteratorOfThisContainer() { Iterator<Integer> iterator = list.iterator(); assertThat(iterator.hasNext(), Is.is(true)); assertThat(iterator.hasNext(), Is.is(true)); assertThat(iterator.next(), Is.is(1)); assertThat(iterator.hasNext(), Is.is(true)); assertThat(iterator.next(), Is.is(2)); assertThat(iterator.hasNext(), Is.is(true)); assertThat(iterator.next(), Is.is(3)); assertThat(iterator.hasNext(), Is.is(false)); } /** * Testing of automatic container increase. */ @Test public void whenAddElementsMoreThanSizeOfContainerThanContainerIncreases() { list.add(4); list.add(5); list.add(6); list.add(7); list.add(8); list.add(9); list.add(10); list.add(11); assertThat(list.get(10), is(11)); } /** * Test with an incorrectly assigned index. */ @Test(expected = IndexOutOfBoundsException.class) public void shoulThrowIndexOfBoundsException() { list.get(3); } /** * Test behavior when the collection was modified during the action of the iterator. */ @Test(expected = ConcurrentModificationException.class) public void shoulThrowConcurrentModificationException() { Iterator<Integer> iterator = list.iterator(); list.add(4); iterator.next(); } }
{'dir': 'java', 'id': '2443403', 'max_stars_count': '0', 'max_stars_repo_name': 'IvanBelyaev/ibelyaev', 'max_stars_repo_path': 'chapter_004/src/test/java/ru/job4j/list/DynamicArrayTest.java', 'n_tokens_mistral': 739, 'n_tokens_neox': 715, 'n_words': 134}
<reponame>kernelcase/autoposter-web package com.facebook_autoposter.robot.core.facebook; import javax.ejb.Stateless; import javax.ejb.TransactionAttribute; import javax.ejb.TransactionAttributeType; import javax.inject.Inject; import com.facebook_autoposter.robot.exception.BusinessException; import com.facebook_autoposter.robot.exception.Validation; import com.facebook_autoposter.robot.persistence.FacebookEntity; import com.facebook_autoposter.robot.persistence.FacebookQuery; @Stateless public class CreateFacebookEJB { @Inject private FacebookQuery facebookQuery; @TransactionAttribute( TransactionAttributeType.REQUIRES_NEW) public Integer createFacebook(FacebookDTO facebookDTO) { // Validate the input Validation.required().setParam("facebookDTO", facebookDTO).validate(); Validation.required() .setParam("idFacebook", facebookDTO.getIdFacebook()) .setParam("facebookUsername", facebookDTO.getFacebookUsername()) .setParam("facebookPassword", facebookDTO.getFacebookPassword()) .validate(); FacebookEntity duplicated = facebookQuery.getFacebookByUsername(facebookDTO.getFacebookUsername()); boolean isDuplicated = duplicated != null; if(isDuplicated) { throw new BusinessException("the facebook account is duplicated"); } FacebookEntity facebookEntity = new FacebookEntity(); facebookEntity.setIdFacebook(facebookDTO.getIdFacebook()); facebookEntity.setFacebookUsername(facebookDTO.getFacebookUsername()); facebookEntity.setFacebookPassword(facebookDTO.getFacebookPassword()); facebookEntity.setFacebookStatus(FacebookStatus.NEW); facebookQuery.save(facebookEntity); return facebookEntity.getIdFacebook(); } @TransactionAttribute( TransactionAttributeType.REQUIRES_NEW) public boolean verify(Integer idFacebook) { boolean verify = false; while(!verify) { FacebookEntity facebookEntity = facebookQuery.getFacebookById(idFacebook); verify = facebookEntity.getFacebookStatus().equals(FacebookStatus.VERIFIED); } return verify; } @TransactionAttribute( TransactionAttributeType.REQUIRES_NEW) public void deleteFacebook(Integer idFacebook) { FacebookEntity facebookEntity = facebookQuery.getFacebookById(idFacebook); facebookQuery.delete(facebookEntity); } }
{'dir': 'java', 'id': '18108284', 'max_stars_count': '0', 'max_stars_repo_name': 'kernelcase/autoposter-web', 'max_stars_repo_path': 'autopost/src/main/java/com/facebook_autoposter/robot/core/facebook/CreateFacebookEJB.java', 'n_tokens_mistral': 707, 'n_tokens_neox': 609, 'n_words': 99}
// // TempDataGenerator.h // MHelloNestedTemplate // // Created by Chen,Meisong on 2017/11/6. // Copyright © 2017年 hellochenms. All rights reserved. // #import <Foundation/Foundation.h> #import "News.h" @interface TempDataGenerator : NSObject + (NSArray<News *> *)newses; @end
{'dir': 'c', 'id': '2158658', 'max_stars_count': '0', 'max_stars_repo_name': 'hellochenms/MHelloNestedTemplate', 'max_stars_repo_path': 'MHelloNestedTemplate/Src/Data/TempDataGenerator.h', 'n_tokens_mistral': 110, 'n_tokens_neox': 100, 'n_words': 24}

A subset (about 3/10) of the stack that has been filtered and decontaminated.

Based on the language distribution in the original data, only the following high-resource programming languages are retained: java, javascript, php, python, c-sharp, typescript, c, cpp, go, html, ruby, kotlin, shell, rust. Non-conventional programming languages such as markdown and json are removed. All non-English files are removed.

This dataset has been decontaminated with respect to the following benchmarks based on n-gram overlap:

  • GLUE (dev set of SST-2, CoLA, QQP, WNLI, RTE, QNLI, MNLI; test set of MPRC)
  • SIQA, PIQA, QASC, CSQA (all dev set)
  • BoolQ (dev set)
  • WinoGrande (dev set)
  • ANLI (test set)
  • ARC easy and challenge (test set)
  • RACE middle and high (test set)
  • MMLU (dev, val, and test sets)
  • MATH, GSM8K (test set)
  • HumanEval (test set)
  • MBPP (all 974 questions)

18 documents are removed during decontamination.

Dataset Statistics

Number of samples: 28,526,818.

Size of downloaded parquet files: 43G.

Downloads last month
2